aboutsummaryrefslogtreecommitdiff
path: root/gdb/findvar.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1996-04-11 21:17:45 +0000
committerStu Grossman <grossman@cygnus>1996-04-11 21:17:45 +0000
commita243a22f4359c557c08d4fd962391c9f70287fec (patch)
tree018f21e57d8d9f12db5fe5f608d8536beb5e34e0 /gdb/findvar.c
parent024e1779233ad7121b2bf40741cfe21b4047770e (diff)
downloadgdb-a243a22f4359c557c08d4fd962391c9f70287fec.zip
gdb-a243a22f4359c557c08d4fd962391c9f70287fec.tar.gz
gdb-a243a22f4359c557c08d4fd962391c9f70287fec.tar.bz2
* dcache.c: Add prototypes. Make many functions static.
* (dcache_peek dcache_fetch dcache_poke): Make dcache_fetch and dcache_poke call dcache_xfer_memory directly in order to fix problems with turning off dcache. dcache_peek is now unnecessary, so it goes away. * defs.h: Define new macros HOST_{FLOAT DOUBLE LONG_DOUBLE}_FORMAT and TARGET_{FLOAT DOUBLE LONG_DOUBLE}_FORMAT to specify a pointer to a struct floatformat. This allows for better handling of targets whose floating point formats differ from the host by more than just byte order. * (floatformat_to_long_double floatformat_from_long_double): Prototypes for new functions in utils.c. * (floatformat_to_doublest floatformat_from_doublest): Prototypes for pointers to floating point conversion functions. The actual function uses either double or long double if the host supports it. * findvar.c (floatformat_to_doublest floatformat_from_doublest): Initialize to point at correct function depending on HAVE_LONG_DOUBLE. * (extract_floating store_floating): Rewrite. Now, if host fp format is the same as the target, we just do a copy. Otherwise, we call floatformat_{to from}_doublest. * remote-nindy.c (nindy_xfer_inferior_memory): Change param `write' to `should_write'. * utils.c (floatformat_to_long_double floatformat_from_long_double): New routines that implement long double versions of functions in libiberty/floatformat.c. * config/i960/tm-i960.h (TARGET_LONG_DOUBLE_FORMAT): Define this for i960 extended real (80 bit) numbers. * nindy-share/nindy.c (ninMemGet ninMemPut): Return number of bytes actually read or written.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r--gdb/findvar.c93
1 files changed, 73 insertions, 20 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 1dce905..7764a21 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -26,6 +26,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "inferior.h"
#include "target.h"
#include "gdb_string.h"
+#include "floatformat.h"
+
+/* This is used to indicate that we don't know the format of the floating point
+ number. Typically, this is useful for native ports, where the actual format
+ is irrelevant, since no conversions will be taking place. */
+
+const struct floatformat floatformat_unknown;
+
+#ifdef HAVE_LONG_DOUBLE
+void (*floatformat_to_doublest)
+ PARAMS ((const struct floatformat *,
+ char *, DOUBLEST *)) = floatformat_to_long_double;
+void (*floatformat_from_doublest)
+ PARAMS ((const struct floatformat *,
+ DOUBLEST *, char *)) = floatformat_from_long_double;
+#else
+void (*floatformat_to_doublest)
+ PARAMS ((const struct floatformat *,
+ char *, DOUBLEST *)) = floatformat_to_double;
+void (*floatformat_from_doublest)
+ PARAMS ((const struct floatformat *,
+ DOUBLEST *, char *)) = floatformat_from_double;
+#endif
/* Registers we shouldn't try to store. */
#if !defined (CANNOT_STORE_REGISTER)
@@ -285,31 +308,50 @@ extract_floating (addr, len)
PTR addr;
int len;
{
+ DOUBLEST dretval;
+
if (len == sizeof (float))
{
- float retval;
- memcpy (&retval, addr, sizeof (retval));
- SWAP_FLOATING (&retval, sizeof (retval));
- return retval;
+ if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
+ {
+ float retval;
+
+ memcpy (&retval, addr, sizeof (retval));
+ return retval;
+ }
+ else
+ floatformat_to_doublest (TARGET_FLOAT_FORMAT, addr, &dretval);
}
else if (len == sizeof (double))
{
- double retval;
- memcpy (&retval, addr, sizeof (retval));
- SWAP_FLOATING (&retval, sizeof (retval));
- return retval;
+ if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
+ {
+ double retval;
+
+ memcpy (&retval, addr, sizeof (retval));
+ return retval;
+ }
+ else
+ floatformat_to_doublest (TARGET_DOUBLE_FORMAT, addr, &dretval);
}
else if (len == sizeof (DOUBLEST))
{
- DOUBLEST retval;
- memcpy (&retval, addr, sizeof (retval));
- SWAP_FLOATING (&retval, sizeof (retval));
- return retval;
+ if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
+ {
+ DOUBLEST retval;
+
+ memcpy (&retval, addr, sizeof (retval));
+ return retval;
+ }
+ else
+ floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, &dretval);
}
else
{
error ("Can't deal with a floating point number of %d bytes.", len);
}
+
+ return dretval;
}
void
@@ -320,21 +362,32 @@ store_floating (addr, len, val)
{
if (len == sizeof (float))
{
- float floatval = val;
- SWAP_FLOATING (&floatval, sizeof (floatval));
- memcpy (addr, &floatval, sizeof (floatval));
+ if (HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT)
+ {
+ float floatval = val;
+
+ memcpy (addr, &floatval, sizeof (floatval));
+ }
+ else
+ floatformat_from_doublest (TARGET_FLOAT_FORMAT, &val, addr);
}
else if (len == sizeof (double))
{
- double doubleval = val;
+ if (HOST_DOUBLE_FORMAT == TARGET_DOUBLE_FORMAT)
+ {
+ double doubleval = val;
- SWAP_FLOATING (&doubleval, sizeof (doubleval));
- memcpy (addr, &doubleval, sizeof (doubleval));
+ memcpy (addr, &doubleval, sizeof (doubleval));
+ }
+ else
+ floatformat_from_doublest (TARGET_DOUBLE_FORMAT, &val, addr);
}
else if (len == sizeof (DOUBLEST))
{
- SWAP_FLOATING (&val, sizeof (val));
- memcpy (addr, &val, sizeof (val));
+ if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
+ memcpy (addr, &val, sizeof (val));
+ else
+ floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr);
}
else
{