aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2001-07-11 08:43:41 +0000
committerMark Kettenis <kettenis@gnu.org>2001-07-11 08:43:41 +0000
commitccb945b81ed53beb1b3849800949c409b4585140 (patch)
treefb50886f24c76d53af94aa6419e480d44a117182
parentf8d13125bf61d0c1e73dde18ebf581e14a4e62a5 (diff)
downloadgdb-ccb945b81ed53beb1b3849800949c409b4585140.zip
gdb-ccb945b81ed53beb1b3849800949c409b4585140.tar.gz
gdb-ccb945b81ed53beb1b3849800949c409b4585140.tar.bz2
* i386-tdep.c (i386_extract_return_value): "Fix" comment.
(i386_store_return_value): Frob FPU status and tag word to make sure the return value is the only value on the FPU stack.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/i386-tdep.c15
2 files changed, 18 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f946cce..0d20664 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2001-07-11 Mark Kettenis <kettenis@gnu.org>
+ * i386-tdep.c (i386_extract_return_value): "Fix" comment.
+ (i386_store_return_value): Frob FPU status and tag word to make
+ sure the return value is the only value on the FPU stack.
+
* config/tm-linux.h: Do not include <signal.h>. Instead provide
reasonable defaults for REALTIME_LO and REALTIME_HI if they're not
already defined.
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 0e3e340..108a707 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -803,7 +803,8 @@ i386_extract_return_value (struct type *type, char *regbuf, char *valbuf)
return;
}
- /* Floating-point return values can be found in %st(0). */
+ /* Floating-point return values can be found in %st(0).
+ FIXME: Does %st(0) always correspond to FP0? */
if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT
&& TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
{
@@ -861,6 +862,8 @@ i386_store_return_value (struct type *type, char *valbuf)
if (TYPE_CODE (type) == TYPE_CODE_FLT)
{
+ unsigned int fstat;
+
if (NUM_FREGS == 0)
{
warning ("Cannot set floating-point return value.");
@@ -889,6 +892,16 @@ i386_store_return_value (struct type *type, char *valbuf)
write_register_bytes (REGISTER_BYTE (FP0_REGNUM), buf,
FPU_REG_RAW_SIZE);
}
+
+ /* Set the top of the floating point register stack to 7. That
+ makes sure that FP0 (which we set above) is indeed %st(0).
+ FIXME: Perhaps we should completely reset the status word? */
+ fstat = read_register (FSTAT_REGNUM);
+ fstat |= (7 << 11);
+ write_register (FSTAT_REGNUM, fstat);
+
+ /* Mark %st(1) through %st(7) as empty. */
+ write_register (FTAG_REGNUM, 0x3fff);
}
else
{