* doublest.c (floatformat_normalize_byteorder): Handle
authorMark Kettenis <kettenis@gnu.org>
Mon, 31 Oct 2005 23:35:52 +0000 (23:35 +0000)
committerMark Kettenis <kettenis@gnu.org>
Mon, 31 Oct 2005 23:35:52 +0000 (23:35 +0000)
floatformat_vax.
(convert_doublest_to_floatformat): Use
floatformat_normalize_byteorder to swap bytes if necessary.
* vax-tdep.c: Include floatformat.h.
(vax_gdbarch_init): Set float_format, double_format,
long_double_format and long_double_bit.
* Makefile.in (vax-tdep.o): Update dependencies.

gdb/ChangeLog
gdb/Makefile.in
gdb/doublest.c
gdb/vax-tdep.c

index fa31f928379ef085bc762ae2de55258d97b9aa6d..6e9658486bc5347d319018b290b30e0943e47301 100644 (file)
@@ -1,3 +1,14 @@
+2005-11-01  Mark Kettenis  <kettenis@gnu.org>
+
+       * doublest.c (floatformat_normalize_byteorder): Handle
+       floatformat_vax.
+       (convert_doublest_to_floatformat): Use
+       floatformat_normalize_byteorder to swap bytes if necessary.
+       * vax-tdep.c: Include floatformat.h.
+       (vax_gdbarch_init): Set float_format, double_format,
+       long_double_format and long_double_bit.
+       * Makefile.in (vax-tdep.o): Update dependencies.
+
 2005-10-31  Christopher Faylor  <cgf@timesys.com>
 
        Change child_ to win32_ throughout.
index 792e48ad6507c8060e8429b918500068c699aa99..8d113523df4f1260b63fd38f38cc175bb6f2520a 100644 (file)
@@ -2747,10 +2747,10 @@ vaxnbsd-tdep.o: vaxnbsd-tdep.c $(defs_h) $(arch_utils_h) $(osabi_h) \
 vaxobsd-tdep.o: vaxobsd-tdep.c  $(defs_h) $(arch_utils_h) $(frame_h) \
        $(frame_unwind_h) $(osabi_h) $(symtab_h) $(trad_frame_h) \
        $(vax_tdep_h) $(gdb_string_h)
-vax-tdep.o: vax-tdep.c $(defs_h) $(arch_utils_h) $(dis_asm_h) $(frame_h) \
-       $(frame_base_h) $(frame_unwind_h) $(gdbcore_h) $(gdbtypes_h) \
-       $(osabi_h) $(regcache_h) $(regset_h) $(trad_frame_h) $(value_h) \
-       $(gdb_string_h) $(vax_tdep_h)
+vax-tdep.o: vax-tdep.c $(defs_h) $(arch_utils_h) $(dis_asm_h) \
+       $(float_format_h)$(frame_h) $(frame_base_h) $(frame_unwind_h) \
+       $(gdbcore_h) $(gdbtypes_h) $(osabi_h) $(regcache_h) $(regset_h) \
+       $(trad_frame_h) $(value_h) $(gdb_string_h) $(vax_tdep_h)
 win32-nat.o: win32-nat.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
        $(exceptions_h) $(gdbcore_h) $(command_h) $(completer_h) \
        $(regcache_h) $(top_h) $(buildsym_h) $(symfile_h) $(objfiles_h) \
index 2562ab672387b470144848be7518bad394734a1a..8045a1ce1392d27675c46f36486a56227fa91285 100644 (file)
@@ -1,8 +1,8 @@
 /* Floating point routines for GDB, the GNU debugger.
 
    Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software
-   Foundation, Inc.
+   1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -110,9 +110,10 @@ get_field (const bfd_byte *data, enum floatformat_byteorders order,
   return result;
 }
 
-/* Normalize the byte order of FROM into TO.  If no normalization is needed
-   then FMT->byteorder is returned and TO is not changed; otherwise the format
-   of the normalized form in TO is returned.  */
+/* Normalize the byte order of FROM into TO.  If no normalization is
+   needed then FMT->byteorder is returned and TO is not changed;
+   otherwise the format of the normalized form in TO is returned.  */
+
 static enum floatformat_byteorders
 floatformat_normalize_byteorder (const struct floatformat *fmt,
                                 const void *from, void *to)
@@ -125,23 +126,40 @@ floatformat_normalize_byteorder (const struct floatformat *fmt,
       || fmt->byteorder == floatformat_big)
     return fmt->byteorder;
 
-  gdb_assert (fmt->byteorder == floatformat_littlebyte_bigword);
-
   words = fmt->totalsize / FLOATFORMAT_CHAR_BIT;
   words >>= 2;
 
   swapout = (unsigned char *)to;
   swapin = (const unsigned char *)from;
 
-  while (words-- > 0)
+  if (fmt->byteorder == floatformat_vax)
+    {
+      while (words-- > 0)
+       {
+         *swapout++ = swapin[1];
+         *swapout++ = swapin[0];
+         *swapout++ = swapin[3];
+         *swapout++ = swapin[2];
+         swapin += 4;
+       }
+      /* This may look weird, since VAX is little-endian, but it is
+        easier to translate to big-endian than to little-endian.  */
+      return floatformat_big;
+    }
+  else
     {
-      *swapout++ = swapin[3];
-      *swapout++ = swapin[2];
-      *swapout++ = swapin[1];
-      *swapout++ = swapin[0];
-      swapin += 4;
+      gdb_assert (fmt->byteorder == floatformat_littlebyte_bigword);
+
+      while (words-- > 0)
+       {
+         *swapout++ = swapin[3];
+         *swapout++ = swapin[2];
+         *swapout++ = swapin[1];
+         *swapout++ = swapin[0];
+         swapin += 4;
+       }
+      return floatformat_big;
     }
-  return floatformat_big;
 }
   
 /* Convert from FMT to a DOUBLEST.
@@ -337,14 +355,13 @@ ldfrexp (long double value, int *eptr)
 #endif /* HAVE_LONG_DOUBLE */
 
 
-/* The converse: convert the DOUBLEST *FROM to an extended float
-   and store where TO points.  Neither FROM nor TO have any alignment
+/* The converse: convert the DOUBLEST *FROM to an extended float and
+   store where TO points.  Neither FROM nor TO have any alignment
    restrictions.  */
 
 static void
 convert_doublest_to_floatformat (CONST struct floatformat *fmt,
-                                const DOUBLEST *from,
-                                void *to)
+                                const DOUBLEST *from, void *to)
 {
   DOUBLEST dfrom;
   int exponent;
@@ -353,10 +370,14 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
   int mant_bits_left;
   unsigned char *uto = (unsigned char *) to;
   enum floatformat_byteorders order = fmt->byteorder;
+  unsigned char newto[FLOATFORMAT_LARGEST_BYTES];
 
-  if (order == floatformat_littlebyte_bigword)
+  if (order != floatformat_little)
     order = floatformat_big;
 
+  if (order != fmt->byteorder)
+    uto = newto;
+
   memcpy (&dfrom, from, sizeof (dfrom));
   memset (uto, 0, (fmt->totalsize + FLOATFORMAT_CHAR_BIT - 1) 
                     / FLOATFORMAT_CHAR_BIT);
@@ -447,24 +468,7 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
  finalize_byteorder:
   /* Do we need to byte-swap the words in the result?  */
   if (order != fmt->byteorder)
-    {
-      int words;
-      unsigned char *curword = uto;
-      unsigned char tmp;
-
-      words = fmt->totalsize / FLOATFORMAT_CHAR_BIT;
-      words >>= 2;
-      while (words-- > 0)
-       {
-         tmp = curword[0];
-         curword[0] = curword[3];
-         curword[3] = tmp;
-         tmp = curword[1];
-         curword[1] = curword[2];
-         curword[2] = tmp;
-         curword += 4;
-       }
-    }
+    floatformat_normalize_byteorder (fmt, newto, to);
 }
 
 /* Check if VAL (which is assumed to be a floating point number whose
index 58d82964fbebceb48b80267a27fc536abfc4454a..625918c1cf9522bd06036050e7d2cacf2efd51e7 100644 (file)
@@ -23,6 +23,7 @@
 #include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "floatformat.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
@@ -476,6 +477,11 @@ vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   gdbarch = gdbarch_alloc (&info, NULL);
 
+  set_gdbarch_float_format (gdbarch, &floatformat_vax_f);
+  set_gdbarch_double_format (gdbarch, &floatformat_vax_d);
+  set_gdbarch_long_double_format (gdbarch, &floatformat_vax_d);
+  set_gdbarch_long_double_bit(gdbarch, 64);
+
   /* Register info */
   set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS);
   set_gdbarch_register_name (gdbarch, vax_register_name);
This page took 0.048149 seconds and 4 git commands to generate.