* inftarg.c (child_thread_alive): New function to see if a
[deliverable/binutils-gdb.git] / gdb / findvar.c
index 922572786b3d109ba51631bc7e753eb37e8bb749..591dc7f987f863c32398f1297565278e436f09cf 100644 (file)
@@ -1,5 +1,5 @@
 /* Find a variable's value in memory, for GDB, the GNU debugger.
-   Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
+   Copyright 1986, 1987, 1989, 1991, 1994, 1995 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "gdbcore.h"
 #include "inferior.h"
 #include "target.h"
+#include <string.h>
 
 static void write_register_pid PARAMS ((int regno, LONGEST val, int pid));
 
@@ -187,9 +188,27 @@ store_address (addr, len, val)
   store_unsigned_integer (addr, len, (LONGEST)val);
 }
 \f
-
-/* There are many problems with floating point cross-debugging
-   in macro SWAP_TARGET_AND_HOST().
+/* Swap LEN bytes at BUFFER between target and host byte-order.  */
+#define SWAP_FLOATING(buffer,len) \
+  do                                                                    \
+    {                                                                   \
+      if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER)                         \
+        {                                                               \
+          char tmp;                                                     \
+          char *p = (char *)(buffer);                                   \
+          char *q = ((char *)(buffer)) + len - 1;                       \
+          for (; p < q; p++, q--)                                       \
+            {                                                           \
+              tmp = *q;                                                 \
+              *q = *p;                                                  \
+              *p = tmp;                                                 \
+            }                                                           \
+        }                                                               \
+    }                                                                   \
+  while (0)
+
+/* There are various problems with the extract_floating and store_floating
+   routines.
 
    1.  These routines only handle byte-swapping, not conversion of
    formats.  So if host is IEEE floating and target is VAX floating,
@@ -213,14 +232,14 @@ extract_floating (addr, len)
     {
       float retval;
       memcpy (&retval, addr, sizeof (retval));
-      SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
+      SWAP_FLOATING (&retval, sizeof (retval));
       return retval;
     }
   else if (len == sizeof (double))
     {
       double retval;
       memcpy (&retval, addr, sizeof (retval));
-      SWAP_TARGET_AND_HOST (&retval, sizeof (retval));
+      SWAP_FLOATING (&retval, sizeof (retval));
       return retval;
     }
   else
@@ -238,12 +257,12 @@ store_floating (addr, len, val)
   if (len == sizeof (float))
     {
       float floatval = val;
-      SWAP_TARGET_AND_HOST (&floatval, sizeof (floatval));
+      SWAP_FLOATING (&floatval, sizeof (floatval));
       memcpy (addr, &floatval, sizeof (floatval));
     }
   else if (len == sizeof (double))
     {
-      SWAP_TARGET_AND_HOST (&val, sizeof (val));
+      SWAP_FLOATING (&val, sizeof (val));
       memcpy (addr, &val, sizeof (val));
     }
   else
@@ -611,7 +630,6 @@ read_register_pid (regno, pid)
 #endif
 
 /* Store VALUE, into the raw contents of register number REGNO.  */
-/* FIXME: The val arg should probably be a LONGEST.  */
 
 void
 write_register (regno, val)
This page took 0.023706 seconds and 4 git commands to generate.