From: Mark Kettenis <kettenis@wins.uva.nl>
To: gdb-patches@sources.redhat.com
Cc: grossman@juniper.dot.net
Subject: [PATCH] Fix returning floating points values for x86
Date: Wed, 11 Jul 2001 01:49:00 -0000 [thread overview]
Message-ID: <200107110849.f6B8nGB19158@delius.kettenis.local> (raw)
Fixes two FAILS in gdb.base/return2.exp.
Stu, I was about to commit this patch when I saw you FreeBSD patch.
Patch is almost identical (modulo comments), so it must be right :-).
I nevertheless took all the credit ;-). I will come back to you on
some of the other stuff in your patch.
Checked in.
Mark
Index: ChangeLog
from 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.
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.31
diff -u -p -r1.31 i386-tdep.c
--- i386-tdep.c 2001/05/09 16:16:33 1.31
+++ i386-tdep.c 2001/07/11 08:38:27
@@ -803,7 +803,8 @@ i386_extract_return_value (struct type *
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 *ty
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 *ty
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
{
next reply other threads:[~2001-07-11 1:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-11 1:49 Mark Kettenis [this message]
2001-07-11 9:13 ` Eli Zaretskii
2001-07-11 13:28 ` Mark Kettenis
2001-07-12 0:00 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200107110849.f6B8nGB19158@delius.kettenis.local \
--to=kettenis@wins.uva.nl \
--cc=gdb-patches@sources.redhat.com \
--cc=grossman@juniper.dot.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox