/* 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.
#include "gdbcore.h"
#include "inferior.h"
#include "target.h"
+#include <string.h>
static void write_register_pid PARAMS ((int regno, LONGEST val, int pid));
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,
{
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
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
#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)