* Patch: Fix ftag error when it is restored from fxsave in gdbserver on x86
@ 2005-11-01 1:09 Qunying Pan
0 siblings, 0 replies; 3+ messages in thread
From: Qunying Pan @ 2005-11-01 1:09 UTC (permalink / raw)
To: gdb-patches; +Cc: qunyingpan
Hello,
This patch fixes ftag error when it is restored from fxsave in gdbserver
on x86. Acceptable?
Thanks,
Qunying
--------------------
The testcase is:
typedef long double doublest;
doublest
add_doublest (doublest u, doublest v)
{
return u + v;
}
int
main ()
{
doublest z = 0.0;
doublest x=1.0,y=2.0;
z = add_doublest(x, y);
printf("%Lf, %Lf %Lf\n", x, y, z);
return 0;
}
When debug with gdbserver, and set breakpoint at add_doublest, the
output z
will be set to nan instead of the expected output 3.0.
The patch is:
2005-10-31 Qunying Pan <qpan@mvista.com>
* gdbserver/i387-fp.c (i387_fxsave_to_cache): Fixing ftag error when
it is restored from fxsave
diff -urNp src/gdb/gdbserver.orig/i387-fp.c src/gdb/gdbserver/i387-fp.c
--- src/gdb/gdbserver.orig/i387-fp.c 2005-06-12 18:59:22.000000000
-0700
+++ src/gdb/gdbserver/i387-fp.c 2005-10-31 16:53:29.000000000 -0800
@@ -247,7 +247,7 @@ i387_fxsave_to_cache (const void *buf)
int i, top;
int st0_regnum = find_regno ("st0");
int xmm0_regnum = find_regno ("xmm0");
- unsigned long val;
+ unsigned long val, val2;
for (i = 0; i < 8; i++)
supply_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i *
16);
@@ -267,7 +267,8 @@ i387_fxsave_to_cache (const void *buf)
/* Generate the form of ftag data that GDB expects. */
top = (fp->fstat >> 11) & 0x7;
- val = 0;
+ val = fp->ftag;
+ val2 = 0;
for (i = 7; i >= 0; i--)
{
int tag;
@@ -275,9 +276,9 @@ i387_fxsave_to_cache (const void *buf)
tag = i387_ftag (fp, (i + 8 - top) % 8);
else
tag = 3;
- val |= tag << (2 * i);
+ val2 |= tag << (2 * i);
}
- supply_register_by_name ("ftag", &val);
+ supply_register_by_name ("ftag", &val2);
val = fp->fiseg & 0xFFFF;
supply_register_by_name ("fiseg", &val);
^ permalink raw reply [flat|nested] 3+ messages in thread* Patch: Fix ftag error when it is restored from fxsave in gdbserver on x86
@ 2005-11-01 17:11 Qunying Pan
2007-03-30 15:33 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Qunying Pan @ 2005-11-01 17:11 UTC (permalink / raw)
To: gdb-patches; +Cc: qunyingpan
Hello,
Sent out to gdb-patches@sources.redhat.com yesterday, but did not get
through I guess. Try again to gdb-patches@sourceware.org.
This patch fixes ftag error when it is restored from fxsave in gdbserver
on x86. Acceptable?
Thanks,
Qunying
--------------------
The testcase is:
typedef long double doublest;
doublest
add_doublest (doublest u, doublest v)
{
return u + v;
}
int
main ()
{
doublest z = 0.0;
doublest x=1.0,y=2.0;
z = add_doublest(x, y);
printf("%Lf, %Lf %Lf\n", x, y, z);
return 0;
}
When debug with gdbserver, and set breakpoint at add_doublest in
cross-gdb, the output z will be set to nan instead of the expected
output 3.0.
The patch is:
2005-10-31 Qunying Pan <qpan@mvista.com>
* gdbserver/i387-fp.c (i387_fxsave_to_cache): Fixing ftag error when
it is restored from fxsave
diff -urNp src/gdb/gdbserver.orig/i387-fp.c src/gdb/gdbserver/i387-fp.c
--- src/gdb/gdbserver.orig/i387-fp.c 2005-06-12 18:59:22.000000000
-0700
+++ src/gdb/gdbserver/i387-fp.c 2005-10-31 16:53:29.000000000 -0800
@@ -247,7 +247,7 @@ i387_fxsave_to_cache (const void *buf)
int i, top;
int st0_regnum = find_regno ("st0");
int xmm0_regnum = find_regno ("xmm0");
- unsigned long val;
+ unsigned long val, val2;
for (i = 0; i < 8; i++)
supply_register (i + st0_regnum, ((char *) &fp->st_space[0]) + i *
16);
@@ -267,7 +267,8 @@ i387_fxsave_to_cache (const void *buf)
/* Generate the form of ftag data that GDB expects. */
top = (fp->fstat >> 11) & 0x7;
- val = 0;
+ val = fp->ftag;
+ val2 = 0;
for (i = 7; i >= 0; i--)
{
int tag;
@@ -275,9 +276,9 @@ i387_fxsave_to_cache (const void *buf)
tag = i387_ftag (fp, (i + 8 - top) % 8);
else
tag = 3;
- val |= tag << (2 * i);
+ val2 |= tag << (2 * i);
}
- supply_register_by_name ("ftag", &val);
+ supply_register_by_name ("ftag", &val2);
val = fp->fiseg & 0xFFFF;
supply_register_by_name ("fiseg", &val);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Patch: Fix ftag error when it is restored from fxsave in gdbserver on x86
2005-11-01 17:11 Qunying Pan
@ 2007-03-30 15:33 ` Daniel Jacobowitz
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-03-30 15:33 UTC (permalink / raw)
To: qunyingpan; +Cc: gdb-patches
On Tue, Nov 01, 2005 at 09:10:57AM -0800, Qunying Pan wrote:
> Hello,
>
> Sent out to gdb-patches@sources.redhat.com yesterday, but did not get
> through I guess. Try again to gdb-patches@sourceware.org.
>
> This patch fixes ftag error when it is restored from fxsave in gdbserver
> on x86. Acceptable?
I've only belatedly had a chance to look at this :-( I ended up using
a different patch, but thank you for your work - it was easy to see
what I'd done (completely) wrong when I wrote the fxsave support.
There was a similar error in the other direction.
Tested on x86_64-linux using gdbserver, where it fixes a failure in
store.exp.
--
Daniel Jacobowitz
CodeSourcery
2007-03-30 Daniel Jacobowitz <dan@codesourcery.com>
* i387-fp.c (i387_cache_to_fxsave): Reinitialize val2 before use.
(i387_fxsave_to_cache): Check fp->ftag while building ftag value.
Index: i387-fp.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/i387-fp.c,v
retrieving revision 1.5
diff -u -p -r1.5 i387-fp.c
--- i387-fp.c 9 Jan 2007 17:59:08 -0000 1.5
+++ i387-fp.c 30 Mar 2007 15:28:45 -0000
@@ -174,6 +174,7 @@ i387_cache_to_fxsave (void *buf)
/* Convert to the simplifed tag form stored in fxsave data. */
collect_register_by_name ("ftag", &val);
val &= 0xFFFF;
+ val2 = 0;
for (i = 7; i >= 0; i--)
{
int tag = (val >> (i * 2)) & 3;
@@ -270,7 +271,7 @@ i387_fxsave_to_cache (const void *buf)
for (i = 7; i >= 0; i--)
{
int tag;
- if (val & (1 << i))
+ if (fp->ftag & (1 << i))
tag = i387_ftag (fp, (i + 8 - top) % 8);
else
tag = 3;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-30 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-01 1:09 Patch: Fix ftag error when it is restored from fxsave in gdbserver on x86 Qunying Pan
2005-11-01 17:11 Qunying Pan
2007-03-30 15:33 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox