Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Qunying Pan" <qpan@mvista.com>
To: <gdb-patches@sourceware.org>
Cc: <qunyingpan@gmail.com>
Subject: Patch: Fix ftag error when it is restored from fxsave in gdbserver on x86
Date: Tue, 01 Nov 2005 17:11:00 -0000	[thread overview]
Message-ID: <000001c5df07$39c341f0$9c0a000a@Nora> (raw)

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);



             reply	other threads:[~2005-11-01 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-01 17:11 Qunying Pan [this message]
2007-03-30 15:33 ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2005-11-01  1:09 Qunying Pan

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='000001c5df07$39c341f0$9c0a000a@Nora' \
    --to=qpan@mvista.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qunyingpan@gmail.com \
    /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