Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: final   i386.floating.record.patch
@ 2009-08-03 14:56 paawan oza
  2009-08-03 20:04 ` Michael Snyder
  2009-08-04  3:20 ` Hui Zhu
  0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-08-03 14:56 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2047 bytes --]

Hi,

please find the patch attached. I have attached as per your suggestion.
I am attaching it from opera browser.

Regards,
Oza.

--- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final   i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Thursday, July 30, 2009, 11:31 PM
> paawan oza wrote:
> > Hi,
> > 
> > please find my answers below.
> > 
> >  1) Are you using a Windows machine to send your
> >  emails?  If so,
> >  is it possible that there is a Unix/Linux
> machine you could
> >  try
> >  sending from?  Your attachments look OK for
> me, but
> >  some people
> >  seem to have had problems with them.
> > 
> > Oza : I used to send all from windows till now.
> > but this patch I sent it from Linux...from opera.
> >   2) And are you using cut-and-paste to
> insert the patches
> >  into the
> >  body of your email?  That would certainly
> cause
> >  problems, because
> >  tabs might be changed into spaces (which is
> exactly what
> >  was
> >  causing patch to fail for me today).
> >  Oza: yes I am using copy-paste....I dont know
> any-other way.
> > because attachmenet are not welcome, so I am not sure
> how I could proceed with this.
> 
> It's not that attachments are not welcome.
> There are various binary encodings for attachments, and
> some of those binary encodings are not welcome.  I
> think
> because there's no open-source way of decoding them.
> 
> If you look at the list, you'll see that attachments are
> used a lot.
> 
> Copy-and-paste, though, in general will not work, because
> it
> usually changes tabs into spaces, which ruins a patch.
> 
> 
> > I will send you updated patch.....may be I might have
> mistaken of old gdb file. sorry for incovenience.
> 
> I think it was just the tabs-to-spaces issue.
> Why don't you try sending an attachment from Opera?
> 
>


      

[-- Attachment #2: i386.record.float.aug-03.patch --]
[-- Type: application/octet-stream, Size: 14116 bytes --]

diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c	2009-07-12 13:46:21.000000000 -0400
+++ gdb.new/i386-tdep.c	2009-07-29 19:51:08.000000000 -0400
@@ -3139,6 +3139,66 @@
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.  
+*/  
+
+static int i386_record_floats (struct gdbarch *gdbarch,  
+                               struct i386_record_s *ir,  
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to 
+     happen.  Currently we store st0-st7 registers, but we need not store all 
+     registers all the time, in future we use ftag register and record only 
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	{
+	  if (record_arch_list_add_reg (ir->regcache, i))
+	    return -1;
+	}
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) && 
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3153,6 +3213,7 @@
   uint32_t tmpu32;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   memset (&ir, 0, sizeof (struct i386_record_s));
   ir.regcache = regcache;
@@ -4188,8 +4249,7 @@
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4203,45 +4263,56 @@
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory.  */
 	  uint32_t addr;
 
 	  if (i386_record_lea_modrm_addr (&ir, &addr))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+              /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+              /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4250,6 +4321,7 @@
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d: 
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4258,9 +4330,14 @@
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c: 
+            case 0x3d: 
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4274,6 +4351,7 @@
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4284,15 +4362,49 @@
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (addr, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (addr, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (addr, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */  
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4302,11 +4414,21 @@
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4329,6 +4451,9 @@
 	    case 0x3e:
 	      if (record_arch_list_add_mem (addr, 10))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x2e:
 	      if (ir.dflag)
@@ -4345,10 +4470,17 @@
 		}
 	      if (record_arch_list_add_mem (addr, 80))
 		return -1;
+              /* Insn fsave.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (addr, 8))
 		return -1;
+              /* Ins fistp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4357,8 +4489,211 @@
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */     
+      else
+        { 
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;	
+	      break;
+	    case 0xd9:    
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;	
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;	
+		      /* If only st(0) is changing, then we have already 
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;	                      
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir, 
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;	 
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4775,12 +5110,18 @@
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;     
       break;
 
       /* int3 */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-08-03 14:56 final i386.floating.record.patch paawan oza
@ 2009-08-03 20:04 ` Michael Snyder
  2009-08-04  3:20 ` Hui Zhu
  1 sibling, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-08-03 20:04 UTC (permalink / raw)
  To: paawan oza; +Cc: gdb-patches, Hui Zhu, Mark Kettenis

paawan oza wrote:
> Hi,
> 
> please find the patch attached. I have attached as per your suggestion.
> I am attaching it from opera browser.

Nicely formatted!  Thanks.

Hui, Mark, do you have any technical review?


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-03 14:56 final i386.floating.record.patch paawan oza
  2009-08-03 20:04 ` Michael Snyder
@ 2009-08-04  3:20 ` Hui Zhu
  2009-08-04 13:03   ` paawan oza
  1 sibling, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-08-04  3:20 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches

Hi Paawan,

Thanks for your work.

I do a some test works with the test code that you sent in before.
I get the values of fp reg with command "info all-registers".

It looks like some fp reg's values not right in replay mode.

In record mode they are:
fctrl          0x37f	895
fstat          0x0	0
ftag           0xffff	65535
fiseg          0x0	0
fioff          0x0	0
---Type <return> to continue, or q <return> to quit---
foseg          0x0	0
fooff          0x0	0
fop            0x0	0

In replay mode they are:
fctrl          0x37f	895
fstat          0x6069	24681
ftag           0x557f	21887
fiseg          0x73	115
fioff          0x8048bfd	134515709
---Type <return> to continue, or q <return> to quit---
foseg          0x7b	123
fooff          0x0	0
fop            0x2e9	745



Thanks,
Hui


#include <stdio.h>
#include <math.h>
#include <stdlib.h>

/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI
FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/

float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;

/* initialization of floats */
void init_floats()
{
 no1 = 10.45;
 no2 = 20.77;
 no3 = 156.89874646;
 no4 = 14.56;
 no5 = 11.11;
 no6 = 66.77;
 no7 = 88.88;
 float_memory = malloc(sizeof(float) * 4);
 *float_memory = 256.256;
 *(float_memory + 1) = 356.356;
 *(float_memory + 2) = 456.456;
 *(float_memory + 3) = 556.556;
}

/* marks FPU stack as empty */
void empty_fpu_stack()
{
 asm ("ffree %st(1) \n\t"
      "ffree %st(2) \n\t"
      "ffree %st(3) \n\t"
      "ffree %st(4) \n\t"
      "ffree %st(5) \n\t"
      "ffree %st(6) \n\t"
      "ffree %st(7)");
}

/* tests floating point arithmatic */
void test_arith_floats()
{
 result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
 printf("result is %f\n",result);

 result = fmodf(no2,no1);
 printf("result is %f\n",result);

 resultd = fmod(x,y);
 printf("result is %f\n",resultd);

 resultld = fmodl(ldy,ldy);
 printf("result is %f\n",resultld);

 result = fabsf(no1);
 printf("result is %f\n",result);

 result = no3 / no4;
 printf("result is %f\n",result);

 result = no1 * no2 * no3 * no4;
 printf("result is %f\n",result);

 result = no1 - no2 - no3 - no4;
 printf("result is %f\n",result);


 asm ("fld %0" : :"m"(*float_memory));
 asm ("fchs");

 /* test for f2xm1 */
 asm ("fld %0" : :"m"(*float_memory));
 asm ("f2xm1");

 asm ("fyl2x");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fxtract");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fprem1");

 /* decrement fpu stack pointer only status register should get affected */
 asm ("fld %0" : :"m"(*float_memory));

 empty_fpu_stack();

 asm ("fld1");
 asm ("fldl2t");
 asm ("fldl2e");
 asm ("fldpi");
 asm ("fldlg2");
 asm ("fldln2");
 asm ("fldz");

 empty_fpu_stack();
 /* finishing emptying the stack */

 result = sqrt(no3);
 printf("result is %f\n",result);
}

void test_log_exp_floats()
{
 result = log10(no3);
 printf("result is %f\n",result);

 result = log(no3);
 printf("result is %f\n",result);

 result = exp10(no3);
 printf("result is %f\n",result);

 result = exp(no3);
 printf("result is %f\n",result);
}

void test_trigo_floats()
{
 result = sin(30);
 printf("result is %f\n",result);

 result = cos(30);
 printf("result is %f\n",result);

 result = tan(30);
 printf("result is %f\n",result);

 result = atan(30);
 printf("result is %f\n",result);

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fptan");

 /* changes st1 and popping register stack */
 asm ("fpatan");

 asm("fincstp");
 asm ("fld %0" : :"m"(float_memory));
 asm ("fsincos");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("frndint");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fld %0" : :"m"(*(float_memory+1)));
 asm ("fscale");

 empty_fpu_stack();

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fsin");
 asm ("fcos");

 /* currently we assume condition likely and always record the registers
 code could be optimized only if the flag is set then record */
 asm ("fld %0" : :"m"(*float_memory));
 asm ("fld %0" : :"m"(*(float_memory+1)));
 asm ("fcmovb %st(1), %st");
 asm ("fcmovbe %st(1), %st");
 asm ("fcmove %st(1), %st");
 asm ("fcmovu %st(1), %st");
 asm ("fcmovnb %st(1), %st");
 asm ("fcmovnbe %st(1), %st");

 empty_fpu_stack();
 /* finished emtyping the stack */
}

void test_compare_floats()
{
   ldy = 88888888888888888888.88;
   if (ldx == ldy)
     ldy = 7777777777777777777777777777.777;
   else
     ldy = 666666666666666666666666666.666;
}

/* test loading and saving of FPU environment */
void test_fpu_env()
{
 asm ("fsave %0" : "=m"(*float_memory) : );
 asm ("frstor %0" : : "m"(*float_memory));
 asm ("fstsw %ax");
}

int main()
{
   init_floats();
   test_arith_floats();
   test_log_exp_floats();
   test_trigo_floats();
   test_compare_floats();
   test_fpu_env();
}




On Mon, Aug 3, 2009 at 22:56, paawan oza<paawan1982@yahoo.com> wrote:
> Hi,
>
> please find the patch attached. I have attached as per your suggestion.
> I am attaching it from opera browser.
>
> Regards,
> Oza.
>
> --- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com> wrote:
>
>> From: Michael Snyder <msnyder@vmware.com>
>> Subject: Re: final   i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Thursday, July 30, 2009, 11:31 PM
>> paawan oza wrote:
>> > Hi,
>> >
>> > please find my answers below.
>> >
>> >  1) Are you using a Windows machine to send your
>> >  emails?  If so,
>> >  is it possible that there is a Unix/Linux
>> machine you could
>> >  try
>> >  sending from?  Your attachments look OK for
>> me, but
>> >  some people
>> >  seem to have had problems with them.
>> >
>> > Oza : I used to send all from windows till now.
>> > but this patch I sent it from Linux...from opera.
>> >   2) And are you using cut-and-paste to
>> insert the patches
>> >  into the
>> >  body of your email?  That would certainly
>> cause
>> >  problems, because
>> >  tabs might be changed into spaces (which is
>> exactly what
>> >  was
>> >  causing patch to fail for me today).
>> >  Oza: yes I am using copy-paste....I dont know
>> any-other way.
>> > because attachmenet are not welcome, so I am not sure
>> how I could proceed with this.
>>
>> It's not that attachments are not welcome.
>> There are various binary encodings for attachments, and
>> some of those binary encodings are not welcome.  I
>> think
>> because there's no open-source way of decoding them.
>>
>> If you look at the list, you'll see that attachments are
>> used a lot.
>>
>> Copy-and-paste, though, in general will not work, because
>> it
>> usually changes tabs into spaces, which ruins a patch.
>>
>>
>> > I will send you updated patch.....may be I might have
>> mistaken of old gdb file. sorry for incovenience.
>>
>> I think it was just the tabs-to-spaces issue.
>> Why don't you try sending an attachment from Opera?
>>
>>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04  3:20 ` Hui Zhu
@ 2009-08-04 13:03   ` paawan oza
  0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-04 13:03 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches


Hi Hui,
I am not sure which test case (insn)  caused this. would you please send me the example (.c file) which you have tried to run ?
please also try to let me know at which insn (at which point it fails).
Regards,
Oza.

--- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, August 4, 2009, 8:49 AM
> Hi Paawan,
> 
> Thanks for your work.
> 
> I do a some test works with the test code that you sent in
> before.
> I get the values of fp reg with command "info
> all-registers".
> 
> It looks like some fp reg's values not right in replay
> mode.
> 
> In record mode they are:
> fctrl         
> 0x37f    895
> fstat         
> 0x0    0
> ftag       
>    0xffff    65535
> fiseg         
> 0x0    0
> fioff         
> 0x0    0
> ---Type <return> to continue, or q <return> to
> quit---
> foseg         
> 0x0    0
> fooff         
> 0x0    0
> fop           
> 0x0    0
> 
> In replay mode they are:
> fctrl         
> 0x37f    895
> fstat         
> 0x6069    24681
> ftag       
>    0x557f    21887
> fiseg         
> 0x73    115
> fioff         
> 0x8048bfd    134515709
> ---Type <return> to continue, or q <return> to
> quit---
> foseg         
> 0x7b    123
> fooff         
> 0x0    0
> fop           
> 0x2e9    745
> 
> 
> 
> Thanks,
> Hui
> 
> 
> #include <stdio.h>
> #include <math.h>
> #include <stdlib.h>
> 
> /* the test intends to test following insns.
> flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp
> fucomp fnstsw fsqrt
> fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t
> fldl2e FLDPI
> FLDLG2 FLDLN2
> FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint
> fscale fsin fcos fcmovb
> fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
> */
> 
> float no1,no2,no3,no4,no5,no6,no7;
> double x = 100.345, y = 25.7789;
> long double ldx = 88888888888888888888.88, ldy =
> 9999999999999999999.99;
> float result,resultd,resultld;
> float *float_memory;
> 
> /* initialization of floats */
> void init_floats()
> {
>  no1 = 10.45;
>  no2 = 20.77;
>  no3 = 156.89874646;
>  no4 = 14.56;
>  no5 = 11.11;
>  no6 = 66.77;
>  no7 = 88.88;
>  float_memory = malloc(sizeof(float) * 4);
>  *float_memory = 256.256;
>  *(float_memory + 1) = 356.356;
>  *(float_memory + 2) = 456.456;
>  *(float_memory + 3) = 556.556;
> }
> 
> /* marks FPU stack as empty */
> void empty_fpu_stack()
> {
>  asm ("ffree %st(1) \n\t"
>       "ffree %st(2) \n\t"
>       "ffree %st(3) \n\t"
>       "ffree %st(4) \n\t"
>       "ffree %st(5) \n\t"
>       "ffree %st(6) \n\t"
>       "ffree %st(7)");
> }
> 
> /* tests floating point arithmatic */
> void test_arith_floats()
> {
>  result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
>  printf("result is %f\n",result);
> 
>  result = fmodf(no2,no1);
>  printf("result is %f\n",result);
> 
>  resultd = fmod(x,y);
>  printf("result is %f\n",resultd);
> 
>  resultld = fmodl(ldy,ldy);
>  printf("result is %f\n",resultld);
> 
>  result = fabsf(no1);
>  printf("result is %f\n",result);
> 
>  result = no3 / no4;
>  printf("result is %f\n",result);
> 
>  result = no1 * no2 * no3 * no4;
>  printf("result is %f\n",result);
> 
>  result = no1 - no2 - no3 - no4;
>  printf("result is %f\n",result);
> 
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fchs");
> 
>  /* test for f2xm1 */
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("f2xm1");
> 
>  asm ("fyl2x");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fxtract");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fprem1");
> 
>  /* decrement fpu stack pointer only status register should
> get affected */
>  asm ("fld %0" : :"m"(*float_memory));
> 
>  empty_fpu_stack();
> 
>  asm ("fld1");
>  asm ("fldl2t");
>  asm ("fldl2e");
>  asm ("fldpi");
>  asm ("fldlg2");
>  asm ("fldln2");
>  asm ("fldz");
> 
>  empty_fpu_stack();
>  /* finishing emptying the stack */
> 
>  result = sqrt(no3);
>  printf("result is %f\n",result);
> }
> 
> void test_log_exp_floats()
> {
>  result = log10(no3);
>  printf("result is %f\n",result);
> 
>  result = log(no3);
>  printf("result is %f\n",result);
> 
>  result = exp10(no3);
>  printf("result is %f\n",result);
> 
>  result = exp(no3);
>  printf("result is %f\n",result);
> }
> 
> void test_trigo_floats()
> {
>  result = sin(30);
>  printf("result is %f\n",result);
> 
>  result = cos(30);
>  printf("result is %f\n",result);
> 
>  result = tan(30);
>  printf("result is %f\n",result);
> 
>  result = atan(30);
>  printf("result is %f\n",result);
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fptan");
> 
>  /* changes st1 and popping register stack */
>  asm ("fpatan");
> 
>  asm("fincstp");
>  asm ("fld %0" : :"m"(float_memory));
>  asm ("fsincos");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("frndint");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fld %0" : :"m"(*(float_memory+1)));
>  asm ("fscale");
> 
>  empty_fpu_stack();
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fsin");
>  asm ("fcos");
> 
>  /* currently we assume condition likely and always record
> the registers
>  code could be optimized only if the flag is set then
> record */
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fld %0" : :"m"(*(float_memory+1)));
>  asm ("fcmovb %st(1), %st");
>  asm ("fcmovbe %st(1), %st");
>  asm ("fcmove %st(1), %st");
>  asm ("fcmovu %st(1), %st");
>  asm ("fcmovnb %st(1), %st");
>  asm ("fcmovnbe %st(1), %st");
> 
>  empty_fpu_stack();
>  /* finished emtyping the stack */
> }
> 
> void test_compare_floats()
> {
>    ldy = 88888888888888888888.88;
>    if (ldx == ldy)
>      ldy =
> 7777777777777777777777777777.777;
>    else
>      ldy =
> 666666666666666666666666666.666;
> }
> 
> /* test loading and saving of FPU environment */
> void test_fpu_env()
> {
>  asm ("fsave %0" : "=m"(*float_memory) : );
>  asm ("frstor %0" : : "m"(*float_memory));
>  asm ("fstsw %ax");
> }
> 
> int main()
> {
>    init_floats();
>    test_arith_floats();
>    test_log_exp_floats();
>    test_trigo_floats();
>    test_compare_floats();
>    test_fpu_env();
> }
> 
> 
> 
> 
> On Mon, Aug 3, 2009 at 22:56, paawan oza<paawan1982@yahoo.com>
> wrote:
> > Hi,
> >
> > please find the patch attached. I have attached as per
> your suggestion.
> > I am attaching it from opera browser.
> >
> > Regards,
> > Oza.
> >
> > --- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com>
> wrote:
> >
> >> From: Michael Snyder <msnyder@vmware.com>
> >> Subject: Re: final   i386.floating.record.patch
> >> To: "paawan oza" <paawan1982@yahoo.com>
> >> Cc: "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Thursday, July 30, 2009, 11:31 PM
> >> paawan oza wrote:
> >> > Hi,
> >> >
> >> > please find my answers below.
> >> >
> >> >  1) Are you using a Windows machine to send
> your
> >> >  emails?  If so,
> >> >  is it possible that there is a Unix/Linux
> >> machine you could
> >> >  try
> >> >  sending from?  Your attachments look OK
> for
> >> me, but
> >> >  some people
> >> >  seem to have had problems with them.
> >> >
> >> > Oza : I used to send all from windows till
> now.
> >> > but this patch I sent it from Linux...from
> opera.
> >> >   2) And are you using cut-and-paste to
> >> insert the patches
> >> >  into the
> >> >  body of your email?  That would certainly
> >> cause
> >> >  problems, because
> >> >  tabs might be changed into spaces (which
> is
> >> exactly what
> >> >  was
> >> >  causing patch to fail for me today).
> >> >  Oza: yes I am using copy-paste....I dont
> know
> >> any-other way.
> >> > because attachmenet are not welcome, so I am
> not sure
> >> how I could proceed with this.
> >>
> >> It's not that attachments are not welcome.
> >> There are various binary encodings for
> attachments, and
> >> some of those binary encodings are not welcome. 
> I
> >> think
> >> because there's no open-source way of decoding
> them.
> >>
> >> If you look at the list, you'll see that
> attachments are
> >> used a lot.
> >>
> >> Copy-and-paste, though, in general will not work,
> because
> >> it
> >> usually changes tabs into spaces, which ruins a
> patch.
> >>
> >>
> >> > I will send you updated patch.....may be I
> might have
> >> mistaken of old gdb file. sorry for incovenience.
> >>
> >> I think it was just the tabs-to-spaces issue.
> >> Why don't you try sending an attachment from
> Opera?
> >>
> >>
> >
> >
> >
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-21 16:59 paawan oza
  2009-08-23  1:32 ` Hui Zhu
  2009-09-09  0:19 ` Michael Snyder
@ 2009-12-10  7:55 ` Hui Zhu
  2 siblings, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-12-10  7:55 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches, Mark Kettenis

Hi guys,

I try this patch in cvs-head with testsuite.  Everything is OK.

So ...

Thanks,
Hui

On Sat, Aug 22, 2009 at 00:30, paawan oza <paawan1982@yahoo.com> wrote:
> Hu Hui,
> please find the ChageLog and floating point patch attached as you suggested.
> Sorry for not pasting it in email-body becasue of space and tabs issues.
> Do we need to update wiki?
> Regards,
> Oza.
>
> --- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> Date: Wednesday, August 19, 2009, 7:47 AM
>> Oops, this is not the bug in fp
>> patch.  Sorry for it.
>>
>> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
>>
>> Everything is OK.
>>
>> I post a new patch that remove space in the tail.
>> I think you need write a changelog.  You can get a
>> example from
>> src/ChangeLog.  Please Let each line doesn't bigger
>> than 72.
>>
>> Thanks,
>> Hui
>>
>> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
>> wrote:
>> > Could you try cvs-head?
>> >
>> > On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >> Hi,
>> >>
>> >> Another analysis and observation is:
>> >>
>> >> I used gdb-6.8.50.20090803 and everything seemed
>> okay.
>> >> Hui used gdb-6.8.50.20090817 and patch was still
>> the same and gdb threw these error.
>> >> was there any thing major changed in gdb ?
>> >>
>> >> and gdb throws error in
>> >> ../../src/gdb/utils.c:1200:
>> >>
>> >> which looks like somebody has allocated memory too
>> much or something has gone wrong in error checking.
>> >>
>> >>
>> >> the floating-point-patch is still the same, if it
>> works fine with gdb-6.8.50.20090803, it is high unlikely
>> that why should it throw memory allocation error with
>> gdb-6.8.50.20090817 (unless system is dangerously low in
>> virtual memory, swap space is full).
>> >>
>> >> Regards,
>> >> Oza.
>> >>
>> >>
>> >>
>> >> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
>> wrote:
>> >>
>> >>> From: paawan oza <paawan1982@yahoo.com>
>> >>> Subject: Re: final i386.floating.record.patch
>> >>> To: "Michael Snyder" <msnyder@vmware.com>,
>> "Hui Zhu" <teawater@gmail.com>
>> >>> Cc: "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>,
>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> >>> Date: Monday, August 17, 2009, 9:40 PM
>> >>> Hi Hui,
>> >>>
>> >>> I test the same and it seems working fine.
>> Another thing I
>> >>> observe is, vertual memory is low problem and
>> may be gdb's
>> >>> virtual address space gets exhausted or any
>> other limit!
>> >>> highly unlikely though.
>> >>>
>> >>> please see the atached log.
>> >>>
>> >>>
>> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
>> >>> # ./gdb ./test_floats
>> >>> GNU gdb (GDB) 6.8.50.20090803
>> >>> Copyright (C) 2009 Free Software Foundation,
>> Inc.
>> >>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> >>> This is free software: you are free to change
>> and
>> >>> redistribute it.
>> >>> There is NO WARRANTY, to the extent permitted
>> by law.
>> >>> Type "show copying"
>> >>> and "show warranty" for details.
>> >>> This GDB was configured as
>> "i686-pc-linux-gnu".
>> >>> For bug reporting instructions, please see:
>> >>> <http://www.gnu.org/software/gdb/bugs/>...
>> >>> Setting up the environment for debugging gdb.
>> >>> Function "internal_error" not defined.
>> >>> Make breakpoint pending on future shared
>> library load? (y
>> >>> or [n]) [answered N; input not from terminal]
>> >>> Function "info_command" not defined.
>> >>> Make breakpoint pending on future shared
>> library load? (y
>> >>> or [n]) [answered N; input not from terminal]
>> >>>
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
>> >>> Error in sourced command file:
>> >>> No breakpoint number 0.
>> >>> (gdb) start
>> >>> Temporary breakpoint 1 at 0x8048c94: file
>> ./test_floats.c,
>> >>> line 196.
>> >>> Starting program:
>> >>>
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
>> >>>
>> >>> Temporary breakpoint 1, main () at
>> ./test_floats.c:196
>> >>> 196         init_floats();
>> >>> (gdb) record
>> >>> (gdb) c
>> >>> Continuing.
>> >>> result is 369.438751
>> >>> result is 10.320001
>> >>> result is 23.008301
>> >>> result is 0.000000
>> >>> result is 10.450000
>> >>> result is 10.776012
>> >>> result is 495830.968750
>> >>> result is -181.778748
>> >>> result is 12.525923
>> >>> result is 2.195619
>> >>> result is 5.055601
>> >>> result is inf
>> >>> result is inf
>> >>> result is -0.988032
>> >>> result is 0.154251
>> >>> result is -6.405331
>> >>> result is 1.537475
>> >>> The next instruction is syscall exit_group.
>> It will
>> >>> make the program exit.  Do you want to stop
>> the
>> >>> program?([y] or n) y
>> >>> Process record: inferior program stopped.
>> >>>
>> >>> Program received signal SIGTRAP,
>> Trace/breakpoint trap.
>> >>> 0xffffe405 in __kernel_vsyscall ()
>> >>> (gdb)
>> >>>
>> >>> Regards,
>> >>> Oza.
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
>> >>> wrote:
>> >>>
>> >>> > From: Hui Zhu <teawater@gmail.com>
>> >>> > Subject: Re: final
>> i386.floating.record.patch
>> >>> > To: "Michael Snyder" <msnyder@vmware.com>
>> >>> > Cc: "paawan oza" <paawan1982@yahoo.com>,
>> >>> "gdb-patches@sourceware.org"
>> >>> <gdb-patches@sourceware.org>,
>> >>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> >>> > Date: Monday, August 17, 2009, 12:06 PM
>> >>> > Get some error with this patch.
>> >>> > cat fp.c
>> >>> > #include <stdio.h>
>> >>> > #include <math.h>
>> >>> > #include <stdlib.h>
>> >>> >
>> >>> > /* the test intends to test following
>> insns.
>> >>> > flds faddp fstps fstpl fldl fxch fabs
>> fdivrp fmulp
>> >>> fsubrp
>> >>> > fucomp fnstsw fsqrt
>> >>> > fchs f2xm1 fyl2x fxtract fprem1 fld
>> fdecstp fld1
>> >>> fldl2t
>> >>> > fldl2e FLDPI
>> >>> > FLDLG2 FLDLN2
>> >>> > FLDZ fincstp ffree fptan fpatan fincstp
>> fsincos
>> >>> frndint
>> >>> > fscale fsin fcos fcmovb
>> >>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe
>> fsave frstor
>> >>> fstsw
>> >>> > */
>> >>> >
>> >>> > float no1,no2,no3,no4,no5,no6,no7;
>> >>> > double x = 100.345, y = 25.7789;
>> >>> > long double ldx =
>> 88888888888888888888.88, ldy =
>> >>> > 9999999999999999999.99;
>> >>> > float result,resultd,resultld;
>> >>> > float *float_memory;
>> >>> >
>> >>> > /* initialization of floats */
>> >>> > void init_floats()
>> >>> > {
>> >>> >  no1 = 10.45;
>> >>> >  no2 = 20.77;
>> >>> >  no3 = 156.89874646;
>> >>> >  no4 = 14.56;
>> >>> >  no5 = 11.11;
>> >>> >  no6 = 66.77;
>> >>> >  no7 = 88.88;
>> >>> >  float_memory = malloc(sizeof(float) *
>> 4);
>> >>> >  *float_memory = 256.256;
>> >>> >  *(float_memory + 1) = 356.356;
>> >>> >  *(float_memory + 2) = 456.456;
>> >>> >  *(float_memory + 3) = 556.556;
>> >>> > }
>> >>> >
>> >>> > /* marks FPU stack as empty */
>> >>> > void empty_fpu_stack()
>> >>> > {
>> >>> >  asm ("ffree %st(1) \n\t"
>> >>> >       "ffree %st(2) \n\t"
>> >>> >       "ffree %st(3) \n\t"
>> >>> >       "ffree %st(4) \n\t"
>> >>> >       "ffree %st(5) \n\t"
>> >>> >       "ffree %st(6) \n\t"
>> >>> >       "ffree %st(7)");
>> >>> > }
>> >>> >
>> >>> > /* tests floating point arithmatic */
>> >>> > void test_arith_floats()
>> >>> > {
>> >>> >  result = no1 + no2 + no3 + no4 + no5 +
>> no6 +
>> >>> no7;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = fmodf(no2,no1);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  resultd = fmod(x,y);
>> >>> >  printf("result is %f\n",resultd);
>> >>> >
>> >>> >  resultld = fmodl(ldy,ldy);
>> >>> >  printf("result is %f\n",resultld);
>> >>> >
>> >>> >  result = fabsf(no1);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no3 / no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no1 * no2 * no3 * no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no1 - no2 - no3 - no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fchs");
>> >>> >
>> >>> >  /* test for f2xm1 */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("f2xm1");
>> >>> >
>> >>> >  asm ("fyl2x");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fxtract");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fprem1");
>> >>> >
>> >>> >  /* decrement fpu stack pointer only
>> status
>> >>> register should
>> >>> > get affected */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >
>> >>> >  asm ("fld1");
>> >>> >  asm ("fldl2t");
>> >>> >  asm ("fldl2e");
>> >>> >  asm ("fldpi");
>> >>> >  asm ("fldlg2");
>> >>> >  asm ("fldln2");
>> >>> >  asm ("fldz");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >  /* finishing emptying the stack */
>> >>> >
>> >>> >  result = sqrt(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> > }
>> >>> >
>> >>> > void test_log_exp_floats()
>> >>> > {
>> >>> >  result = log10(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = log(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = exp10(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = exp(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> > }
>> >>> >
>> >>> > void test_trigo_floats()
>> >>> > {
>> >>> >  result = sin(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = cos(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = tan(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = atan(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fptan");
>> >>> >
>> >>> >  /* changes st1 and popping register
>> stack */
>> >>> >  asm ("fpatan");
>> >>> >
>> >>> >  asm("fincstp");
>> >>> >  asm ("fld %0" : :"m"(float_memory));
>> >>> >  asm ("fsincos");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("frndint");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >>> >  asm ("fscale");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fsin");
>> >>> >  asm ("fcos");
>> >>> >
>> >>> >  /* currently we assume condition likely
>> and
>> >>> always record
>> >>> > the registers
>> >>> >  code could be optimized only if the
>> flag is set
>> >>> then
>> >>> > record */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >>> >  asm ("fcmovb %st(1), %st");
>> >>> >  asm ("fcmovbe %st(1), %st");
>> >>> >  asm ("fcmove %st(1), %st");
>> >>> >  asm ("fcmovu %st(1), %st");
>> >>> >  asm ("fcmovnb %st(1), %st");
>> >>> >  asm ("fcmovnbe %st(1), %st");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >  /* finished emtyping the stack */
>> >>> > }
>> >>> >
>> >>> > void test_compare_floats()
>> >>> > {
>> >>> >    ldy = 88888888888888888888.88;
>> >>> >    if (ldx == ldy)
>> >>> >      ldy =
>> >>> > 7777777777777777777777777777.777;
>> >>> >    else
>> >>> >      ldy =
>> >>> > 666666666666666666666666666.666;
>> >>> > }
>> >>> >
>> >>> > /* test loading and saving of FPU
>> environment */
>> >>> > void test_fpu_env()
>> >>> > {
>> >>> >  asm ("fsave %0" : "=m"(*float_memory) :
>> );
>> >>> >  asm ("frstor %0" : :
>> "m"(*float_memory));
>> >>> >  asm ("fstsw %ax");
>> >>> > }
>> >>> >
>> >>> > int main()
>> >>> > {
>> >>> >    init_floats();
>> >>> >    test_arith_floats();
>> >>> >    test_log_exp_floats();
>> >>> >    test_trigo_floats();
>> >>> >    test_compare_floats();
>> >>> >    test_fpu_env();
>> >>> > }
>> >>> >
>> >>> >
>> >>> >
>> >>> > ./gdb ./a.out
>> >>> > GNU gdb (GDB) 6.8.50.20090817-cvs
>> >>> > Copyright (C) 2009 Free Software
>> Foundation, Inc.
>> >>> > License GPLv3+: GNU GPL version 3 or
>> later <http://gnu.org/licenses/gpl.html>
>> >>> > This is free software: you are free to
>> change and
>> >>> > redistribute it.
>> >>> > There is NO WARRANTY, to the extent
>> permitted by
>> >>> law.
>> >>> > Type "show copying"
>> >>> > and "show warranty" for details.
>> >>> > This GDB was configured as
>> "i686-pc-linux-gnu".
>> >>> > For bug reporting instructions, please
>> see:
>> >>> > <http://www.gnu.org/software/gdb/bugs/>...
>> >>> > Setting up the environment for debugging
>> gdb.
>> >>> > Function "internal_error" not defined.
>> >>> > Make breakpoint pending on future shared
>> library load?
>> >>> (y
>> >>> > or [n])
>> >>> > [answered N; input not from terminal]
>> >>> > Function "info_command" not defined.
>> >>> > Make breakpoint pending on future shared
>> library load?
>> >>> (y
>> >>> > or [n])
>> >>> > [answered N; input not from terminal]
>> >>> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
>> Error in
>> >>> sourced
>> >>> > command file:
>> >>> > No breakpoint number 0.
>> >>> > (gdb) start
>> >>> > During symbol reading, DW_AT_name missing
>> from
>> >>> > DW_TAG_base_type.
>> >>> > Temporary breakpoint 1 at 0x8048c74: file
>> fp.c, line
>> >>> 196.
>> >>> > Starting program:
>> /home/teawater/gdb/bgdbno/gdb/a.out
>> >>> >
>> >>> > Temporary breakpoint 1, main () at
>> fp.c:196
>> >>> > 196       init_floats();
>> >>> > (gdb) record
>> >>> > (gdb) c
>> >>> > Continuing.
>> >>> > ../../src/gdb/utils.c:1200:
>> internal-error: virtual
>> >>> memory
>> >>> > exhausted.
>> >>> > A problem internal to GDB has been
>> detected,
>> >>> > further debugging may prove unreliable.
>> >>> > Quit this debugging session? (y or n) n
>> >>> > ../../src/gdb/utils.c:1200:
>> internal-error: virtual
>> >>> memory
>> >>> > exhausted.
>> >>> > A problem internal to GDB has been
>> detected,
>> >>> > further debugging may prove unreliable.
>> >>> > Create a core file of GDB? (y or n) n
>> >>> >
>> >>> > Program received signal SIGTRAP,
>> Trace/breakpoint
>> >>> trap.
>> >>> > 0xb7eba9bc in memcpy () from
>> >>> /lib/tls/i686/cmov/libc.so.6
>> >>> > (gdb) quit
>> >>> > A debugging session is active.
>> >>> >
>> >>> >     Inferior 1 [process 15657] will
>> be
>> >>> > killed.
>> >>> >
>> >>> > Quit anyway? (y or n) y
>> >>> >
>> >>> >
>> >>> > Thanks,
>> >>> > Hui
>> >>> >
>> >>> > On Mon, Aug 17, 2009 at 05:16, Michael
>> Snyder<msnyder@vmware.com>
>> >>> > wrote:
>> >>> > > paawan oza wrote:
>> >>> > >>
>> >>> > >> Hi Hui & Michael,
>> >>> > >> Now we revert status registers
>> also.
>> >>> > >> please find the patch attached.
>> >>> > >> I am sorry, if I am not pasting
>> the patch in
>> >>> > email-body due to tabs&spaces
>> >>> > >> problem faced by Michael last
>> time.
>> >>> > >> Regards,
>> >>> > >> Oza.
>> >>> > >
>> >>> > > Looking good!
>> >>> > >
>> >>> > > There were some conflicts between
>> your changes
>> >>> and a
>> >>> > check-in that
>> >>> > > happened after your submission  --
>>  I've taken
>> >>> the
>> >>> > liberty of merging
>> >>> > > your changes with the cvs head,
>> fixing up the
>> >>> > conflicts.  Hope you
>> >>> > > don't mind  --  merged patch
>> attached.
>> >>> > >
>> >>> > > I'll review your tests next.
>> >>> > >
>> >>> > > Can you write up a change log entry
>> for this
>> >>> patch?
>> >>> > >
>> >>> > > Hui, Mark, any more comments?
>> >>> > >
>> >>> > > Cheers,
>> >>> > > Michael
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >>
>> >
>>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-09-09  0:19 ` Michael Snyder
  2009-09-10  1:13   ` paawan oza
@ 2009-09-26  9:33   ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-09-26  9:33 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, gdb-patches

Hi,
I have been in constant touch with osf and relevant papers, papers are expected to arrive in a week or so.
mean while, I will start working on MMX support for i386.
Regards,
Oza.



--- On Wed, 9/9/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Wednesday, September 9, 2009, 5:47 AM
> paawan oza wrote:
> > Hu Hui,
> > please find the ChageLog and floating point patch
> attached as you suggested..
> > Sorry for not pasting it in email-body becasue of
> space and tabs issues.
> > Do we need to update wiki?
> > Regards,
> > Oza.
> 
> To help keep this patch alive (while waiting for Oza's
> copyright
> assignment), I have taken the liberty of merging and
> updating it
> against today's cvs head (Sept. 8, 2009).
> 
> 2009-08-21  Oza Pawandeep  <paawan1982@yahoo.com>
> 
>         * i386-tdep.c:  Support
> for floating point recording.
>         Records and Replay the i386
> floating point registers,
>         of i387 FPU.
> 
> 
> 
> -----Inline Attachment Follows-----
> 
> 





^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-09-09  0:19 ` Michael Snyder
@ 2009-09-10  1:13   ` paawan oza
  2009-09-26  9:33   ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-09-10  1:13 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, gdb-patches

Thank you Michael.
I am still waiting for the papers to arrive.
I do not have much idea, how much more we need to wait :(
once I get the papers and get them signed, we are ready to go :)
Regards,
Oza.


--- On Wed, 9/9/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Wednesday, September 9, 2009, 5:47 AM
> paawan oza wrote:
> > Hu Hui,
> > please find the ChageLog and floating point patch
> attached as you suggested.
> > Sorry for not pasting it in email-body becasue of
> space and tabs issues.
> > Do we need to update wiki?
> > Regards,
> > Oza.
> 
> To help keep this patch alive (while waiting for Oza's
> copyright
> assignment), I have taken the liberty of merging and
> updating it
> against today's cvs head (Sept. 8, 2009).
> 
> 2009-08-21  Oza Pawandeep  <paawan1982@yahoo.com>
> 
>         * i386-tdep.c:  Support
> for floating point recording.
>         Records and Replay the i386
> floating point registers,
>         of i387 FPU.
> 
> 
> 
> -----Inline Attachment Follows-----
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-21 16:59 paawan oza
  2009-08-23  1:32 ` Hui Zhu
@ 2009-09-09  0:19 ` Michael Snyder
  2009-09-10  1:13   ` paawan oza
  2009-09-26  9:33   ` paawan oza
  2009-12-10  7:55 ` Hui Zhu
  2 siblings, 2 replies; 40+ messages in thread
From: Michael Snyder @ 2009-09-09  0:19 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

paawan oza wrote:
> Hu Hui,
> please find the ChageLog and floating point patch attached as you suggested.
> Sorry for not pasting it in email-body becasue of space and tabs issues.
> Do we need to update wiki?
> Regards,
> Oza.

To help keep this patch alive (while waiting for Oza's copyright
assignment), I have taken the liberty of merging and updating it
against today's cvs head (Sept. 8, 2009).

2009-08-21  Oza Pawandeep  <paawan1982@yahoo.com>

         * i386-tdep.c:  Support for floating point recording.
         Records and Replay the i386 floating point registers,
         of i387 FPU.



[-- Attachment #2: i386.record.float.sept-08.patch --]
[-- Type: text/x-patch, Size: 14464 bytes --]

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.287
diff -u -p -r1.287 i386-tdep.c
--- i386-tdep.c	7 Sep 2009 11:09:33 -0000	1.287
+++ i386-tdep.c	9 Sep 2009 00:18:20 -0000
@@ -3196,6 +3196,74 @@ i386_record_push (struct i386_record_s *
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.
+*/
+
+static int i386_record_floats (struct gdbarch *gdbarch,
+                               struct i386_record_s *ir,
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to
+     happen.  Currently we store st0-st7 registers, but we need not store all
+     registers all the time, in future we use ftag register and record only
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	      {
+	      if (record_arch_list_add_reg (ir->regcache, i))
+	        return -1;
+	      }
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  if(I386_SAVE_FPU_ENV != iregnum)
+    {
+    for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+      if (record_arch_list_add_reg (ir->regcache, i))
+        return -1;
+      }
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3214,6 +3282,7 @@ i386_process_record (struct gdbarch *gdb
   ULONGEST tmpulongest;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int rex = 0;
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
@@ -4262,8 +4331,7 @@ reswitch:
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4277,45 +4345,56 @@ reswitch:
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory. */
 	  uint64_t tmpu64;
 
 	  if (i386_record_lea_modrm_addr (&ir, &tmpu64))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+	      /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+	      /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4324,6 +4403,7 @@ reswitch:
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d:
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4332,9 +4412,14 @@ reswitch:
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c:
+            case 0x3d:
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4348,6 +4433,7 @@ reswitch:
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4358,15 +4444,49 @@ reswitch:
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (tmpu64, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (tmpu64, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (tmpu64, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4376,11 +4496,21 @@ reswitch:
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4398,6 +4528,9 @@ reswitch:
 	    case 0x2f:
 	      if (record_arch_list_add_mem (tmpu64, 2))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x1f:
 	    case 0x3e:
@@ -4419,10 +4552,17 @@ reswitch:
 		}
 	      if (record_arch_list_add_mem (tmpu64, 80))
 		return -1;
+	      /* Insn fsave.  */
+	      if (i386_record_floats (gdbarch, &ir,
+				      I386_SAVE_FPU_ENV_REG_STACK))
+		return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (tmpu64, 8))
 		return -1;
+	      /* Insn fistp.  */
+	      if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4431,8 +4571,211 @@ reswitch:
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */
+      else
+        {
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;
+	      break;
+	    case 0xd9:
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      /* If only st(0) is changing, then we have already
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir,
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir,
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4836,12 +5179,18 @@ reswitch:
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;
       break;
 
       /* int3 */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-23  3:00   ` Michael Snyder
  2009-08-23  9:04     ` paawan oza
@ 2009-08-23  9:29     ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-23  9:29 UTC (permalink / raw)
  To: Hui Zhu, Michael Snyder; +Cc: gdb-patches, Mark Kettenis

Hi,

I have gone through 'contributing' documentation. I have gone through licensing related sections.

But I am not very sure what are the exact things/stpes invloved ?
Also I could not find template forms for the copyright.

please help me with these.
I think as this is for the first time, Open Source Ethics are bit unclear to me. 
But may be next time it will be smooth sailing : )

Regards,
Oza.


--- On Sun, 8/23/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "Hui Zhu" <teawater@gmail.com>
> Cc: "paawan oza" <paawan1982@yahoo.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
> Date: Sunday, August 23, 2009, 6:58 AM
> We just need a copyright assignment,
> and then one of us can check it in.
> 
> Oza, have you sent in your copyright assignment?
> If not, see the file src/gdb/CONTRIBUTE.
> 
> 
> Hui Zhu wrote:
> > I think this patch is OK.  How do we continue?
> > 
> > Thanks,
> > Hui
> > 
> > On Sat, Aug 22, 2009 at 00:30, paawan oza<paawan1982@yahoo.com>
> wrote:
> >> Hu Hui,
> >> please find the ChageLog and floating point patch
> attached as you suggested.
> >> Sorry for not pasting it in email-body becasue of
> space and tabs issues.
> >> Do we need to update wiki?
> >> Regards,
> >> Oza.
> >>
> >> --- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >>
> >>> From: Hui Zhu <teawater@gmail.com>
> >>> Subject: Re: final i386.floating.record.patch
> >>> To: "paawan oza" <paawan1982@yahoo.com>
> >>> Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>> Date: Wednesday, August 19, 2009, 7:47 AM
> >>> Oops, this is not the bug in fp
> >>> patch.  Sorry for it.
> >>>
> >>> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
> >>>
> >>> Everything is OK.
> >>>
> >>> I post a new patch that remove space in the
> tail.
> >>> I think you need write a changelog.  You
> can get a
> >>> example from
> >>> src/ChangeLog.  Please Let each line
> doesn't bigger
> >>> than 72.
> >>>
> >>> Thanks,
> >>> Hui
> >>>
> >>> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
> >>> wrote:
> >>>> Could you try cvs-head?
> >>>>
> >>>> On Tue, Aug 18, 2009 at 21:48, paawan
> oza<paawan1982@yahoo.com>
> >>> wrote:
> >>>>> Hi,
> >>>>>
> >>>>> Another analysis and observation is:
> >>>>>
> >>>>> I used gdb-6.8.50.20090803 and
> everything seemed
> >>> okay.
> >>>>> Hui used gdb-6.8.50.20090817 and patch
> was still
> >>> the same and gdb threw these error.
> >>>>> was there any thing major changed in
> gdb ?
> >>>>>
> >>>>> and gdb throws error in
> >>>>> ../../src/gdb/utils.c:1200:
> >>>>>
> >>>>> which looks like somebody has
> allocated memory too
> >>> much or something has gone wrong in error
> checking.
> >>>>>
> >>>>> the floating-point-patch is still the
> same, if it
> >>> works fine with gdb-6.8.50.20090803, it is
> high unlikely
> >>> that why should it throw memory allocation
> error with
> >>> gdb-6.8.50.20090817 (unless system is
> dangerously low in
> >>> virtual memory, swap space is full).
> >>>>> Regards,
> >>>>> Oza.
> >>>>>
> >>>>>
> >>>>>
> >>>>> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
> >>> wrote:
> >>>>>> From: paawan oza <paawan1982@yahoo.com>
> >>>>>> Subject: Re: final
> i386.floating.record.patch
> >>>>>> To: "Michael Snyder" <msnyder@vmware.com>,
> >>> "Hui Zhu" <teawater@gmail.com>
> >>>>>> Cc: "gdb-patches@sourceware.org"
> >>> <gdb-patches@sourceware.org>,
> >>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>>>>> Date: Monday, August 17, 2009,
> 9:40 PM
> >>>>>> Hi Hui,
> >>>>>>
> >>>>>> I test the same and it seems
> working fine.
> >>> Another thing I
> >>>>>> observe is, vertual memory is low
> problem and
> >>> may be gdb's
> >>>>>> virtual address space gets
> exhausted or any
> >>> other limit!
> >>>>>> highly unlikely though.
> >>>>>>
> >>>>>> please see the atached log.
> >>>>>>
> >>>>>>
> >>>
> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
> >>>>>> # ./gdb ./test_floats
> >>>>>> GNU gdb (GDB) 6.8.50.20090803
> >>>>>> Copyright (C) 2009 Free Software
> Foundation,
> >>> Inc.
> >>>>>> License GPLv3+: GNU GPL version 3
> or later
> >>> <http://gnu.org/licenses/gpl.html>
> >>>>>> This is free software: you are
> free to change
> >>> and
> >>>>>> redistribute it.
> >>>>>> There is NO WARRANTY, to the
> extent permitted
> >>> by law.
> >>>>>> Type "show copying"
> >>>>>> and "show warranty" for details.
> >>>>>> This GDB was configured as
> >>> "i686-pc-linux-gnu".
> >>>>>> For bug reporting instructions,
> please see:
> >>>>>> <http://www.gnu.org/software/gdb/bugs/>...
> >>>>>> Setting up the environment for
> debugging gdb.
> >>>>>> Function "internal_error" not
> defined.
> >>>>>> Make breakpoint pending on future
> shared
> >>> library load? (y
> >>>>>> or [n]) [answered N; input not
> from terminal]
> >>>>>> Function "info_command" not
> defined.
> >>>>>> Make breakpoint pending on future
> shared
> >>> library load? (y
> >>>>>> or [n]) [answered N; input not
> from terminal]
> >>>>>>
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
> >>>>>> Error in sourced command file:
> >>>>>> No breakpoint number 0.
> >>>>>> (gdb) start
> >>>>>> Temporary breakpoint 1 at
> 0x8048c94: file
> >>> ./test_floats.c,
> >>>>>> line 196.
> >>>>>> Starting program:
> >>>>>>
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
> >>>>>> Temporary breakpoint 1, main ()
> at
> >>> ./test_floats.c:196
> >>>>>> 196     
>    init_floats();
> >>>>>> (gdb) record
> >>>>>> (gdb) c
> >>>>>> Continuing.
> >>>>>> result is 369.438751
> >>>>>> result is 10.320001
> >>>>>> result is 23.008301
> >>>>>> result is 0.000000
> >>>>>> result is 10.450000
> >>>>>> result is 10.776012
> >>>>>> result is 495830.968750
> >>>>>> result is -181.778748
> >>>>>> result is 12.525923
> >>>>>> result is 2.195619
> >>>>>> result is 5.055601
> >>>>>> result is inf
> >>>>>> result is inf
> >>>>>> result is -0.988032
> >>>>>> result is 0.154251
> >>>>>> result is -6.405331
> >>>>>> result is 1.537475
> >>>>>> The next instruction is syscall
> exit_group.
> >>> It will
> >>>>>> make the program exit.  Do
> you want to stop
> >>> the
> >>>>>> program?([y] or n) y
> >>>>>> Process record: inferior program
> stopped.
> >>>>>>
> >>>>>> Program received signal SIGTRAP,
> >>> Trace/breakpoint trap.
> >>>>>> 0xffffe405 in __kernel_vsyscall
> ()
> >>>>>> (gdb)
> >>>>>>
> >>>>>> Regards,
> >>>>>> Oza.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --- On Mon, 8/17/09, Hui Zhu
> <teawater@gmail.com>
> >>>>>> wrote:
> >>>>>>
> >>>>>>> From: Hui Zhu <teawater@gmail.com>
> >>>>>>> Subject: Re: final
> >>> i386.floating.record.patch
> >>>>>>> To: "Michael Snyder" <msnyder@vmware.com>
> >>>>>>> Cc: "paawan oza" <paawan1982@yahoo.com>,
> >>>>>> "gdb-patches@sourceware.org"
> >>>>>> <gdb-patches@sourceware.org>,
> >>>>>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>>>>>> Date: Monday, August 17, 2009,
> 12:06 PM
> >>>>>>> Get some error with this
> patch.
> >>>>>>> cat fp.c
> >>>>>>> #include <stdio.h>
> >>>>>>> #include <math.h>
> >>>>>>> #include <stdlib.h>
> >>>>>>>
> >>>>>>> /* the test intends to test
> following
> >>> insns.
> >>>>>>> flds faddp fstps fstpl fldl
> fxch fabs
> >>> fdivrp fmulp
> >>>>>> fsubrp
> >>>>>>> fucomp fnstsw fsqrt
> >>>>>>> fchs f2xm1 fyl2x fxtract
> fprem1 fld
> >>> fdecstp fld1
> >>>>>> fldl2t
> >>>>>>> fldl2e FLDPI
> >>>>>>> FLDLG2 FLDLN2
> >>>>>>> FLDZ fincstp ffree fptan
> fpatan fincstp
> >>> fsincos
> >>>>>> frndint
> >>>>>>> fscale fsin fcos fcmovb
> >>>>>>> fcmovbe fcmove fcmovu fcmovnb
> fcmovnbe
> >>> fsave frstor
> >>>>>> fstsw
> >>>>>>> */
> >>>>>>>
> >>>>>>> float
> no1,no2,no3,no4,no5,no6,no7;
> >>>>>>> double x = 100.345, y =
> 25.7789;
> >>>>>>> long double ldx =
> >>> 88888888888888888888.88, ldy =
> >>>>>>> 9999999999999999999.99;
> >>>>>>> float
> result,resultd,resultld;
> >>>>>>> float *float_memory;
> >>>>>>>
> >>>>>>> /* initialization of floats
> */
> >>>>>>> void init_floats()
> >>>>>>> {
> >>>>>>>  no1 = 10.45;
> >>>>>>>  no2 = 20.77;
> >>>>>>>  no3 = 156.89874646;
> >>>>>>>  no4 = 14.56;
> >>>>>>>  no5 = 11.11;
> >>>>>>>  no6 = 66.77;
> >>>>>>>  no7 = 88.88;
> >>>>>>>  float_memory =
> malloc(sizeof(float) *
> >>> 4);
> >>>>>>>  *float_memory =
> 256.256;
> >>>>>>>  *(float_memory + 1) =
> 356.356;
> >>>>>>>  *(float_memory + 2) =
> 456.456;
> >>>>>>>  *(float_memory + 3) =
> 556.556;
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* marks FPU stack as empty
> */
> >>>>>>> void empty_fpu_stack()
> >>>>>>> {
> >>>>>>>  asm ("ffree %st(1)
> \n\t"
> >>>>>>>   
>    "ffree %st(2) \n\t"
> >>>>>>>   
>    "ffree %st(3) \n\t"
> >>>>>>>   
>    "ffree %st(4) \n\t"
> >>>>>>>   
>    "ffree %st(5) \n\t"
> >>>>>>>   
>    "ffree %st(6) \n\t"
> >>>>>>>   
>    "ffree %st(7)");
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* tests floating point
> arithmatic */
> >>>>>>> void test_arith_floats()
> >>>>>>> {
> >>>>>>>  result = no1 + no2 + no3
> + no4 + no5 +
> >>> no6 +
> >>>>>> no7;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result =
> fmodf(no2,no1);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  resultd = fmod(x,y);
> >>>>>>>  printf("result is
> %f\n",resultd);
> >>>>>>>
> >>>>>>>  resultld =
> fmodl(ldy,ldy);
> >>>>>>>  printf("result is
> %f\n",resultld);
> >>>>>>>
> >>>>>>>  result = fabsf(no1);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no3 / no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no1 * no2 * no3
> * no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no1 - no2 - no3
> - no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fchs");
> >>>>>>>
> >>>>>>>  /* test for f2xm1 */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("f2xm1");
> >>>>>>>
> >>>>>>>  asm ("fyl2x");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fxtract");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fprem1");
> >>>>>>>
> >>>>>>>  /* decrement fpu stack
> pointer only
> >>> status
> >>>>>> register should
> >>>>>>> get affected */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>
> >>>>>>>  asm ("fld1");
> >>>>>>>  asm ("fldl2t");
> >>>>>>>  asm ("fldl2e");
> >>>>>>>  asm ("fldpi");
> >>>>>>>  asm ("fldlg2");
> >>>>>>>  asm ("fldln2");
> >>>>>>>  asm ("fldz");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>  /* finishing emptying
> the stack */
> >>>>>>>
> >>>>>>>  result = sqrt(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_log_exp_floats()
> >>>>>>> {
> >>>>>>>  result = log10(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = log(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = exp10(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = exp(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_trigo_floats()
> >>>>>>> {
> >>>>>>>  result = sin(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = cos(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = tan(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = atan(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fptan");
> >>>>>>>
> >>>>>>>  /* changes st1 and
> popping register
> >>> stack */
> >>>>>>>  asm ("fpatan");
> >>>>>>>
> >>>>>>>  asm("fincstp");
> >>>>>>>  asm ("fld %0" :
> :"m"(float_memory));
> >>>>>>>  asm ("fsincos");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("frndint");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fld %0" :
> >>> :"m"(*(float_memory+1)));
> >>>>>>>  asm ("fscale");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fsin");
> >>>>>>>  asm ("fcos");
> >>>>>>>
> >>>>>>>  /* currently we assume
> condition likely
> >>> and
> >>>>>> always record
> >>>>>>> the registers
> >>>>>>>  code could be optimized
> only if the
> >>> flag is set
> >>>>>> then
> >>>>>>> record */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fld %0" :
> >>> :"m"(*(float_memory+1)));
> >>>>>>>  asm ("fcmovb %st(1),
> %st");
> >>>>>>>  asm ("fcmovbe %st(1),
> %st");
> >>>>>>>  asm ("fcmove %st(1),
> %st");
> >>>>>>>  asm ("fcmovu %st(1),
> %st");
> >>>>>>>  asm ("fcmovnb %st(1),
> %st");
> >>>>>>>  asm ("fcmovnbe %st(1),
> %st");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>  /* finished emtyping the
> stack */
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_compare_floats()
> >>>>>>> {
> >>>>>>>    ldy =
> 88888888888888888888.88;
> >>>>>>>    if (ldx == ldy)
> >>>>>>>      ldy =
> >>>>>>>
> 7777777777777777777777777777.777;
> >>>>>>>    else
> >>>>>>>      ldy =
> >>>>>>>
> 666666666666666666666666666.666;
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* test loading and saving of
> FPU
> >>> environment */
> >>>>>>> void test_fpu_env()
> >>>>>>> {
> >>>>>>>  asm ("fsave %0" :
> "=m"(*float_memory) :
> >>> );
> >>>>>>>  asm ("frstor %0" : :
> >>> "m"(*float_memory));
> >>>>>>>  asm ("fstsw %ax");
> >>>>>>> }
> >>>>>>>
> >>>>>>> int main()
> >>>>>>> {
> >>>>>>>    init_floats();
> >>>>>>>   
> test_arith_floats();
> >>>>>>>   
> test_log_exp_floats();
> >>>>>>>   
> test_trigo_floats();
> >>>>>>>   
> test_compare_floats();
> >>>>>>>    test_fpu_env();
> >>>>>>> }
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ./gdb ./a.out
> >>>>>>> GNU gdb (GDB)
> 6.8.50.20090817-cvs
> >>>>>>> Copyright (C) 2009 Free
> Software
> >>> Foundation, Inc.
> >>>>>>> License GPLv3+: GNU GPL
> version 3 or
> >>> later <http://gnu.org/licenses/gpl.html>
> >>>>>>> This is free software: you are
> free to
> >>> change and
> >>>>>>> redistribute it.
> >>>>>>> There is NO WARRANTY, to the
> extent
> >>> permitted by
> >>>>>> law.
> >>>>>>> Type "show copying"
> >>>>>>> and "show warranty" for
> details.
> >>>>>>> This GDB was configured as
> >>> "i686-pc-linux-gnu".
> >>>>>>> For bug reporting
> instructions, please
> >>> see:
> >>>>>>> <http://www.gnu.org/software/gdb/bugs/>...
> >>>>>>> Setting up the environment for
> debugging
> >>> gdb.
> >>>>>>> Function "internal_error" not
> defined.
> >>>>>>> Make breakpoint pending on
> future shared
> >>> library load?
> >>>>>> (y
> >>>>>>> or [n])
> >>>>>>> [answered N; input not from
> terminal]
> >>>>>>> Function "info_command" not
> defined.
> >>>>>>> Make breakpoint pending on
> future shared
> >>> library load?
> >>>>>> (y
> >>>>>>> or [n])
> >>>>>>> [answered N; input not from
> terminal]
> >>>>>>>
> /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
> >>> Error in
> >>>>>> sourced
> >>>>>>> command file:
> >>>>>>> No breakpoint number 0.
> >>>>>>> (gdb) start
> >>>>>>> During symbol reading,
> DW_AT_name missing
> >>> from
> >>>>>>> DW_TAG_base_type.
> >>>>>>> Temporary breakpoint 1 at
> 0x8048c74: file
> >>> fp.c, line
> >>>>>> 196.
> >>>>>>> Starting program:
> >>> /home/teawater/gdb/bgdbno/gdb/a.out
> >>>>>>> Temporary breakpoint 1, main
> () at
> >>> fp.c:196
> >>>>>>> 196   
>    init_floats();
> >>>>>>> (gdb) record
> >>>>>>> (gdb) c
> >>>>>>> Continuing.
> >>>>>>> ../../src/gdb/utils.c:1200:
> >>> internal-error: virtual
> >>>>>> memory
> >>>>>>> exhausted.
> >>>>>>> A problem internal to GDB has
> been
> >>> detected,
> >>>>>>> further debugging may prove
> unreliable.
> >>>>>>> Quit this debugging session?
> (y or n) n
> >>>>>>> ../../src/gdb/utils.c:1200:
> >>> internal-error: virtual
> >>>>>> memory
> >>>>>>> exhausted.
> >>>>>>> A problem internal to GDB has
> been
> >>> detected,
> >>>>>>> further debugging may prove
> unreliable.
> >>>>>>> Create a core file of GDB? (y
> or n) n
> >>>>>>>
> >>>>>>> Program received signal
> SIGTRAP,
> >>> Trace/breakpoint
> >>>>>> trap.
> >>>>>>> 0xb7eba9bc in memcpy () from
> >>>>>> /lib/tls/i686/cmov/libc.so.6
> >>>>>>> (gdb) quit
> >>>>>>> A debugging session is
> active.
> >>>>>>>
> >>>>>>> 
>    Inferior 1 [process 15657] will
> >>> be
> >>>>>>> killed.
> >>>>>>>
> >>>>>>> Quit anyway? (y or n) y
> >>>>>>>
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>> Hui
> >>>>>>>
> >>>>>>> On Mon, Aug 17, 2009 at 05:16,
> Michael
> >>> Snyder<msnyder@vmware.com>
> >>>>>>> wrote:
> >>>>>>>> paawan oza wrote:
> >>>>>>>>> Hi Hui & Michael,
> >>>>>>>>> Now we revert status
> registers
> >>> also.
> >>>>>>>>> please find the patch
> attached.
> >>>>>>>>> I am sorry, if I am
> not pasting
> >>> the patch in
> >>>>>>> email-body due to
> tabs&spaces
> >>>>>>>>> problem faced by
> Michael last
> >>> time.
> >>>>>>>>> Regards,
> >>>>>>>>> Oza.
> >>>>>>>> Looking good!
> >>>>>>>>
> >>>>>>>> There were some conflicts
> between
> >>> your changes
> >>>>>> and a
> >>>>>>> check-in that
> >>>>>>>> happened after your
> submission  --
> >>>  I've taken
> >>>>>> the
> >>>>>>> liberty of merging
> >>>>>>>> your changes with the cvs
> head,
> >>> fixing up the
> >>>>>>> conflicts.  Hope you
> >>>>>>>> don't mind  -- 
> merged patch
> >>> attached.
> >>>>>>>> I'll review your tests
> next.
> >>>>>>>>
> >>>>>>>> Can you write up a change
> log entry
> >>> for this
> >>>>>> patch?
> >>>>>>>> Hui, Mark, any more
> comments?
> >>>>>>>>
> >>>>>>>> Cheers,
> >>>>>>>> Michael
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>
> >>
> 
> 


 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-23  3:00   ` Michael Snyder
@ 2009-08-23  9:04     ` paawan oza
  2009-08-23  9:29     ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-23  9:04 UTC (permalink / raw)
  To: Hui Zhu, Michael Snyder; +Cc: gdb-patches, Mark Kettenis

Hi,

I have gone through 'contributing' documentation. I have gone through licensing related sections.

But I am not very sure what are the exact things/stpes invloved ?
Also I could not find template forms for the copyright.

please help me with these.
I think as this is for the first time, Open Source Ethics are bit unclear to me. 
But may be next time it will be smooth sailing : )

Regards,
Oza.


--- On Sun, 8/23/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "Hui Zhu" <teawater@gmail.com>
> Cc: "paawan oza" <paawan1982@yahoo.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
> Date: Sunday, August 23, 2009, 6:58 AM
> We just need a copyright assignment,
> and then one of us can check it in.
> 
> Oza, have you sent in your copyright assignment?
> If not, see the file src/gdb/CONTRIBUTE.
> 
> 
> Hui Zhu wrote:
> > I think this patch is OK.  How do we continue?
> > 
> > Thanks,
> > Hui
> > 
> > On Sat, Aug 22, 2009 at 00:30, paawan oza<paawan1982@yahoo.com>
> wrote:
> >> Hu Hui,
> >> please find the ChageLog and floating point patch
> attached as you suggested.
> >> Sorry for not pasting it in email-body becasue of
> space and tabs issues.
> >> Do we need to update wiki?
> >> Regards,
> >> Oza.
> >>
> >> --- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >>
> >>> From: Hui Zhu <teawater@gmail.com>
> >>> Subject: Re: final i386.floating.record.patch
> >>> To: "paawan oza" <paawan1982@yahoo.com>
> >>> Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>> Date: Wednesday, August 19, 2009, 7:47 AM
> >>> Oops, this is not the bug in fp
> >>> patch.  Sorry for it.
> >>>
> >>> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
> >>>
> >>> Everything is OK.
> >>>
> >>> I post a new patch that remove space in the
> tail.
> >>> I think you need write a changelog.  You
> can get a
> >>> example from
> >>> src/ChangeLog.  Please Let each line
> doesn't bigger
> >>> than 72.
> >>>
> >>> Thanks,
> >>> Hui
> >>>
> >>> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
> >>> wrote:
> >>>> Could you try cvs-head?
> >>>>
> >>>> On Tue, Aug 18, 2009 at 21:48, paawan
> oza<paawan1982@yahoo.com>
> >>> wrote:
> >>>>> Hi,
> >>>>>
> >>>>> Another analysis and observation is:
> >>>>>
> >>>>> I used gdb-6.8.50.20090803 and
> everything seemed
> >>> okay.
> >>>>> Hui used gdb-6.8.50.20090817 and patch
> was still
> >>> the same and gdb threw these error.
> >>>>> was there any thing major changed in
> gdb ?
> >>>>>
> >>>>> and gdb throws error in
> >>>>> ../../src/gdb/utils.c:1200:
> >>>>>
> >>>>> which looks like somebody has
> allocated memory too
> >>> much or something has gone wrong in error
> checking.
> >>>>>
> >>>>> the floating-point-patch is still the
> same, if it
> >>> works fine with gdb-6.8.50.20090803, it is
> high unlikely
> >>> that why should it throw memory allocation
> error with
> >>> gdb-6.8.50.20090817 (unless system is
> dangerously low in
> >>> virtual memory, swap space is full).
> >>>>> Regards,
> >>>>> Oza.
> >>>>>
> >>>>>
> >>>>>
> >>>>> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
> >>> wrote:
> >>>>>> From: paawan oza <paawan1982@yahoo.com>
> >>>>>> Subject: Re: final
> i386.floating.record.patch
> >>>>>> To: "Michael Snyder" <msnyder@vmware.com>,
> >>> "Hui Zhu" <teawater@gmail.com>
> >>>>>> Cc: "gdb-patches@sourceware.org"
> >>> <gdb-patches@sourceware.org>,
> >>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>>>>> Date: Monday, August 17, 2009,
> 9:40 PM
> >>>>>> Hi Hui,
> >>>>>>
> >>>>>> I test the same and it seems
> working fine.
> >>> Another thing I
> >>>>>> observe is, vertual memory is low
> problem and
> >>> may be gdb's
> >>>>>> virtual address space gets
> exhausted or any
> >>> other limit!
> >>>>>> highly unlikely though.
> >>>>>>
> >>>>>> please see the atached log.
> >>>>>>
> >>>>>>
> >>>
> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
> >>>>>> # ./gdb ./test_floats
> >>>>>> GNU gdb (GDB) 6.8.50.20090803
> >>>>>> Copyright (C) 2009 Free Software
> Foundation,
> >>> Inc.
> >>>>>> License GPLv3+: GNU GPL version 3
> or later
> >>> <http://gnu.org/licenses/gpl.html>
> >>>>>> This is free software: you are
> free to change
> >>> and
> >>>>>> redistribute it.
> >>>>>> There is NO WARRANTY, to the
> extent permitted
> >>> by law.
> >>>>>> Type "show copying"
> >>>>>> and "show warranty" for details.
> >>>>>> This GDB was configured as
> >>> "i686-pc-linux-gnu".
> >>>>>> For bug reporting instructions,
> please see:
> >>>>>> <http://www.gnu.org/software/gdb/bugs/>...
> >>>>>> Setting up the environment for
> debugging gdb.
> >>>>>> Function "internal_error" not
> defined.
> >>>>>> Make breakpoint pending on future
> shared
> >>> library load? (y
> >>>>>> or [n]) [answered N; input not
> from terminal]
> >>>>>> Function "info_command" not
> defined.
> >>>>>> Make breakpoint pending on future
> shared
> >>> library load? (y
> >>>>>> or [n]) [answered N; input not
> from terminal]
> >>>>>>
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
> >>>>>> Error in sourced command file:
> >>>>>> No breakpoint number 0.
> >>>>>> (gdb) start
> >>>>>> Temporary breakpoint 1 at
> 0x8048c94: file
> >>> ./test_floats.c,
> >>>>>> line 196.
> >>>>>> Starting program:
> >>>>>>
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
> >>>>>> Temporary breakpoint 1, main ()
> at
> >>> ./test_floats.c:196
> >>>>>> 196     
>    init_floats();
> >>>>>> (gdb) record
> >>>>>> (gdb) c
> >>>>>> Continuing.
> >>>>>> result is 369.438751
> >>>>>> result is 10.320001
> >>>>>> result is 23.008301
> >>>>>> result is 0.000000
> >>>>>> result is 10.450000
> >>>>>> result is 10.776012
> >>>>>> result is 495830.968750
> >>>>>> result is -181.778748
> >>>>>> result is 12.525923
> >>>>>> result is 2.195619
> >>>>>> result is 5.055601
> >>>>>> result is inf
> >>>>>> result is inf
> >>>>>> result is -0.988032
> >>>>>> result is 0.154251
> >>>>>> result is -6.405331
> >>>>>> result is 1.537475
> >>>>>> The next instruction is syscall
> exit_group.
> >>> It will
> >>>>>> make the program exit.  Do
> you want to stop
> >>> the
> >>>>>> program?([y] or n) y
> >>>>>> Process record: inferior program
> stopped.
> >>>>>>
> >>>>>> Program received signal SIGTRAP,
> >>> Trace/breakpoint trap.
> >>>>>> 0xffffe405 in __kernel_vsyscall
> ()
> >>>>>> (gdb)
> >>>>>>
> >>>>>> Regards,
> >>>>>> Oza.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> --- On Mon, 8/17/09, Hui Zhu
> <teawater@gmail.com>
> >>>>>> wrote:
> >>>>>>
> >>>>>>> From: Hui Zhu <teawater@gmail.com>
> >>>>>>> Subject: Re: final
> >>> i386.floating.record.patch
> >>>>>>> To: "Michael Snyder" <msnyder@vmware.com>
> >>>>>>> Cc: "paawan oza" <paawan1982@yahoo.com>,
> >>>>>> "gdb-patches@sourceware.org"
> >>>>>> <gdb-patches@sourceware.org>,
> >>>>>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>>>>>> Date: Monday, August 17, 2009,
> 12:06 PM
> >>>>>>> Get some error with this
> patch.
> >>>>>>> cat fp.c
> >>>>>>> #include <stdio.h>
> >>>>>>> #include <math.h>
> >>>>>>> #include <stdlib.h>
> >>>>>>>
> >>>>>>> /* the test intends to test
> following
> >>> insns.
> >>>>>>> flds faddp fstps fstpl fldl
> fxch fabs
> >>> fdivrp fmulp
> >>>>>> fsubrp
> >>>>>>> fucomp fnstsw fsqrt
> >>>>>>> fchs f2xm1 fyl2x fxtract
> fprem1 fld
> >>> fdecstp fld1
> >>>>>> fldl2t
> >>>>>>> fldl2e FLDPI
> >>>>>>> FLDLG2 FLDLN2
> >>>>>>> FLDZ fincstp ffree fptan
> fpatan fincstp
> >>> fsincos
> >>>>>> frndint
> >>>>>>> fscale fsin fcos fcmovb
> >>>>>>> fcmovbe fcmove fcmovu fcmovnb
> fcmovnbe
> >>> fsave frstor
> >>>>>> fstsw
> >>>>>>> */
> >>>>>>>
> >>>>>>> float
> no1,no2,no3,no4,no5,no6,no7;
> >>>>>>> double x = 100.345, y =
> 25.7789;
> >>>>>>> long double ldx =
> >>> 88888888888888888888.88, ldy =
> >>>>>>> 9999999999999999999.99;
> >>>>>>> float
> result,resultd,resultld;
> >>>>>>> float *float_memory;
> >>>>>>>
> >>>>>>> /* initialization of floats
> */
> >>>>>>> void init_floats()
> >>>>>>> {
> >>>>>>>  no1 = 10.45;
> >>>>>>>  no2 = 20.77;
> >>>>>>>  no3 = 156.89874646;
> >>>>>>>  no4 = 14.56;
> >>>>>>>  no5 = 11.11;
> >>>>>>>  no6 = 66.77;
> >>>>>>>  no7 = 88.88;
> >>>>>>>  float_memory =
> malloc(sizeof(float) *
> >>> 4);
> >>>>>>>  *float_memory =
> 256.256;
> >>>>>>>  *(float_memory + 1) =
> 356.356;
> >>>>>>>  *(float_memory + 2) =
> 456.456;
> >>>>>>>  *(float_memory + 3) =
> 556.556;
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* marks FPU stack as empty
> */
> >>>>>>> void empty_fpu_stack()
> >>>>>>> {
> >>>>>>>  asm ("ffree %st(1)
> \n\t"
> >>>>>>>   
>    "ffree %st(2) \n\t"
> >>>>>>>   
>    "ffree %st(3) \n\t"
> >>>>>>>   
>    "ffree %st(4) \n\t"
> >>>>>>>   
>    "ffree %st(5) \n\t"
> >>>>>>>   
>    "ffree %st(6) \n\t"
> >>>>>>>   
>    "ffree %st(7)");
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* tests floating point
> arithmatic */
> >>>>>>> void test_arith_floats()
> >>>>>>> {
> >>>>>>>  result = no1 + no2 + no3
> + no4 + no5 +
> >>> no6 +
> >>>>>> no7;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result =
> fmodf(no2,no1);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  resultd = fmod(x,y);
> >>>>>>>  printf("result is
> %f\n",resultd);
> >>>>>>>
> >>>>>>>  resultld =
> fmodl(ldy,ldy);
> >>>>>>>  printf("result is
> %f\n",resultld);
> >>>>>>>
> >>>>>>>  result = fabsf(no1);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no3 / no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no1 * no2 * no3
> * no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = no1 - no2 - no3
> - no4;
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fchs");
> >>>>>>>
> >>>>>>>  /* test for f2xm1 */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("f2xm1");
> >>>>>>>
> >>>>>>>  asm ("fyl2x");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fxtract");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fprem1");
> >>>>>>>
> >>>>>>>  /* decrement fpu stack
> pointer only
> >>> status
> >>>>>> register should
> >>>>>>> get affected */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>
> >>>>>>>  asm ("fld1");
> >>>>>>>  asm ("fldl2t");
> >>>>>>>  asm ("fldl2e");
> >>>>>>>  asm ("fldpi");
> >>>>>>>  asm ("fldlg2");
> >>>>>>>  asm ("fldln2");
> >>>>>>>  asm ("fldz");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>  /* finishing emptying
> the stack */
> >>>>>>>
> >>>>>>>  result = sqrt(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_log_exp_floats()
> >>>>>>> {
> >>>>>>>  result = log10(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = log(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = exp10(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = exp(no3);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_trigo_floats()
> >>>>>>> {
> >>>>>>>  result = sin(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = cos(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = tan(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  result = atan(30);
> >>>>>>>  printf("result is
> %f\n",result);
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fptan");
> >>>>>>>
> >>>>>>>  /* changes st1 and
> popping register
> >>> stack */
> >>>>>>>  asm ("fpatan");
> >>>>>>>
> >>>>>>>  asm("fincstp");
> >>>>>>>  asm ("fld %0" :
> :"m"(float_memory));
> >>>>>>>  asm ("fsincos");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("frndint");
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fld %0" :
> >>> :"m"(*(float_memory+1)));
> >>>>>>>  asm ("fscale");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fsin");
> >>>>>>>  asm ("fcos");
> >>>>>>>
> >>>>>>>  /* currently we assume
> condition likely
> >>> and
> >>>>>> always record
> >>>>>>> the registers
> >>>>>>>  code could be optimized
> only if the
> >>> flag is set
> >>>>>> then
> >>>>>>> record */
> >>>>>>>  asm ("fld %0" :
> :"m"(*float_memory));
> >>>>>>>  asm ("fld %0" :
> >>> :"m"(*(float_memory+1)));
> >>>>>>>  asm ("fcmovb %st(1),
> %st");
> >>>>>>>  asm ("fcmovbe %st(1),
> %st");
> >>>>>>>  asm ("fcmove %st(1),
> %st");
> >>>>>>>  asm ("fcmovu %st(1),
> %st");
> >>>>>>>  asm ("fcmovnb %st(1),
> %st");
> >>>>>>>  asm ("fcmovnbe %st(1),
> %st");
> >>>>>>>
> >>>>>>>  empty_fpu_stack();
> >>>>>>>  /* finished emtyping the
> stack */
> >>>>>>> }
> >>>>>>>
> >>>>>>> void test_compare_floats()
> >>>>>>> {
> >>>>>>>    ldy =
> 88888888888888888888.88;
> >>>>>>>    if (ldx == ldy)
> >>>>>>>      ldy =
> >>>>>>>
> 7777777777777777777777777777.777;
> >>>>>>>    else
> >>>>>>>      ldy =
> >>>>>>>
> 666666666666666666666666666.666;
> >>>>>>> }
> >>>>>>>
> >>>>>>> /* test loading and saving of
> FPU
> >>> environment */
> >>>>>>> void test_fpu_env()
> >>>>>>> {
> >>>>>>>  asm ("fsave %0" :
> "=m"(*float_memory) :
> >>> );
> >>>>>>>  asm ("frstor %0" : :
> >>> "m"(*float_memory));
> >>>>>>>  asm ("fstsw %ax");
> >>>>>>> }
> >>>>>>>
> >>>>>>> int main()
> >>>>>>> {
> >>>>>>>    init_floats();
> >>>>>>>   
> test_arith_floats();
> >>>>>>>   
> test_log_exp_floats();
> >>>>>>>   
> test_trigo_floats();
> >>>>>>>   
> test_compare_floats();
> >>>>>>>    test_fpu_env();
> >>>>>>> }
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ./gdb ./a.out
> >>>>>>> GNU gdb (GDB)
> 6.8.50.20090817-cvs
> >>>>>>> Copyright (C) 2009 Free
> Software
> >>> Foundation, Inc.
> >>>>>>> License GPLv3+: GNU GPL
> version 3 or
> >>> later <http://gnu.org/licenses/gpl.html>
> >>>>>>> This is free software: you are
> free to
> >>> change and
> >>>>>>> redistribute it.
> >>>>>>> There is NO WARRANTY, to the
> extent
> >>> permitted by
> >>>>>> law.
> >>>>>>> Type "show copying"
> >>>>>>> and "show warranty" for
> details.
> >>>>>>> This GDB was configured as
> >>> "i686-pc-linux-gnu".
> >>>>>>> For bug reporting
> instructions, please
> >>> see:
> >>>>>>> <http://www.gnu.org/software/gdb/bugs/>...
> >>>>>>> Setting up the environment for
> debugging
> >>> gdb.
> >>>>>>> Function "internal_error" not
> defined.
> >>>>>>> Make breakpoint pending on
> future shared
> >>> library load?
> >>>>>> (y
> >>>>>>> or [n])
> >>>>>>> [answered N; input not from
> terminal]
> >>>>>>> Function "info_command" not
> defined.
> >>>>>>> Make breakpoint pending on
> future shared
> >>> library load?
> >>>>>> (y
> >>>>>>> or [n])
> >>>>>>> [answered N; input not from
> terminal]
> >>>>>>>
> /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
> >>> Error in
> >>>>>> sourced
> >>>>>>> command file:
> >>>>>>> No breakpoint number 0.
> >>>>>>> (gdb) start
> >>>>>>> During symbol reading,
> DW_AT_name missing
> >>> from
> >>>>>>> DW_TAG_base_type.
> >>>>>>> Temporary breakpoint 1 at
> 0x8048c74: file
> >>> fp.c, line
> >>>>>> 196.
> >>>>>>> Starting program:
> >>> /home/teawater/gdb/bgdbno/gdb/a.out
> >>>>>>> Temporary breakpoint 1, main
> () at
> >>> fp.c:196
> >>>>>>> 196   
>    init_floats();
> >>>>>>> (gdb) record
> >>>>>>> (gdb) c
> >>>>>>> Continuing.
> >>>>>>> ../../src/gdb/utils.c:1200:
> >>> internal-error: virtual
> >>>>>> memory
> >>>>>>> exhausted.
> >>>>>>> A problem internal to GDB has
> been
> >>> detected,
> >>>>>>> further debugging may prove
> unreliable.
> >>>>>>> Quit this debugging session?
> (y or n) n
> >>>>>>> ../../src/gdb/utils.c:1200:
> >>> internal-error: virtual
> >>>>>> memory
> >>>>>>> exhausted.
> >>>>>>> A problem internal to GDB has
> been
> >>> detected,
> >>>>>>> further debugging may prove
> unreliable.
> >>>>>>> Create a core file of GDB? (y
> or n) n
> >>>>>>>
> >>>>>>> Program received signal
> SIGTRAP,
> >>> Trace/breakpoint
> >>>>>> trap.
> >>>>>>> 0xb7eba9bc in memcpy () from
> >>>>>> /lib/tls/i686/cmov/libc.so.6
> >>>>>>> (gdb) quit
> >>>>>>> A debugging session is
> active.
> >>>>>>>
> >>>>>>> 
>    Inferior 1 [process 15657] will
> >>> be
> >>>>>>> killed.
> >>>>>>>
> >>>>>>> Quit anyway? (y or n) y
> >>>>>>>
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>> Hui
> >>>>>>>
> >>>>>>> On Mon, Aug 17, 2009 at 05:16,
> Michael
> >>> Snyder<msnyder@vmware.com>
> >>>>>>> wrote:
> >>>>>>>> paawan oza wrote:
> >>>>>>>>> Hi Hui & Michael,
> >>>>>>>>> Now we revert status
> registers
> >>> also.
> >>>>>>>>> please find the patch
> attached.
> >>>>>>>>> I am sorry, if I am
> not pasting
> >>> the patch in
> >>>>>>> email-body due to
> tabs&spaces
> >>>>>>>>> problem faced by
> Michael last
> >>> time.
> >>>>>>>>> Regards,
> >>>>>>>>> Oza.
> >>>>>>>> Looking good!
> >>>>>>>>
> >>>>>>>> There were some conflicts
> between
> >>> your changes
> >>>>>> and a
> >>>>>>> check-in that
> >>>>>>>> happened after your
> submission  --
> >>>  I've taken
> >>>>>> the
> >>>>>>> liberty of merging
> >>>>>>>> your changes with the cvs
> head,
> >>> fixing up the
> >>>>>>> conflicts.  Hope you
> >>>>>>>> don't mind  -- 
> merged patch
> >>> attached.
> >>>>>>>> I'll review your tests
> next.
> >>>>>>>>
> >>>>>>>> Can you write up a change
> log entry
> >>> for this
> >>>>>> patch?
> >>>>>>>> Hui, Mark, any more
> comments?
> >>>>>>>>
> >>>>>>>> Cheers,
> >>>>>>>> Michael
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>
> >>
> 
> 


 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-23  1:32 ` Hui Zhu
@ 2009-08-23  3:00   ` Michael Snyder
  2009-08-23  9:04     ` paawan oza
  2009-08-23  9:29     ` paawan oza
  0 siblings, 2 replies; 40+ messages in thread
From: Michael Snyder @ 2009-08-23  3:00 UTC (permalink / raw)
  To: Hui Zhu; +Cc: paawan oza, gdb-patches, Mark Kettenis

We just need a copyright assignment, and then one of us can check it in.

Oza, have you sent in your copyright assignment?
If not, see the file src/gdb/CONTRIBUTE.


Hui Zhu wrote:
> I think this patch is OK.  How do we continue?
> 
> Thanks,
> Hui
> 
> On Sat, Aug 22, 2009 at 00:30, paawan oza<paawan1982@yahoo.com> wrote:
>> Hu Hui,
>> please find the ChageLog and floating point patch attached as you suggested.
>> Sorry for not pasting it in email-body becasue of space and tabs issues.
>> Do we need to update wiki?
>> Regards,
>> Oza.
>>
>> --- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com> wrote:
>>
>>> From: Hui Zhu <teawater@gmail.com>
>>> Subject: Re: final i386.floating.record.patch
>>> To: "paawan oza" <paawan1982@yahoo.com>
>>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
>>> Date: Wednesday, August 19, 2009, 7:47 AM
>>> Oops, this is not the bug in fp
>>> patch.  Sorry for it.
>>>
>>> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
>>>
>>> Everything is OK.
>>>
>>> I post a new patch that remove space in the tail.
>>> I think you need write a changelog.  You can get a
>>> example from
>>> src/ChangeLog.  Please Let each line doesn't bigger
>>> than 72.
>>>
>>> Thanks,
>>> Hui
>>>
>>> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
>>> wrote:
>>>> Could you try cvs-head?
>>>>
>>>> On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com>
>>> wrote:
>>>>> Hi,
>>>>>
>>>>> Another analysis and observation is:
>>>>>
>>>>> I used gdb-6.8.50.20090803 and everything seemed
>>> okay.
>>>>> Hui used gdb-6.8.50.20090817 and patch was still
>>> the same and gdb threw these error.
>>>>> was there any thing major changed in gdb ?
>>>>>
>>>>> and gdb throws error in
>>>>> ../../src/gdb/utils.c:1200:
>>>>>
>>>>> which looks like somebody has allocated memory too
>>> much or something has gone wrong in error checking.
>>>>>
>>>>> the floating-point-patch is still the same, if it
>>> works fine with gdb-6.8.50.20090803, it is high unlikely
>>> that why should it throw memory allocation error with
>>> gdb-6.8.50.20090817 (unless system is dangerously low in
>>> virtual memory, swap space is full).
>>>>> Regards,
>>>>> Oza.
>>>>>
>>>>>
>>>>>
>>>>> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
>>> wrote:
>>>>>> From: paawan oza <paawan1982@yahoo.com>
>>>>>> Subject: Re: final i386.floating.record.patch
>>>>>> To: "Michael Snyder" <msnyder@vmware.com>,
>>> "Hui Zhu" <teawater@gmail.com>
>>>>>> Cc: "gdb-patches@sourceware.org"
>>> <gdb-patches@sourceware.org>,
>>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>>>>>> Date: Monday, August 17, 2009, 9:40 PM
>>>>>> Hi Hui,
>>>>>>
>>>>>> I test the same and it seems working fine.
>>> Another thing I
>>>>>> observe is, vertual memory is low problem and
>>> may be gdb's
>>>>>> virtual address space gets exhausted or any
>>> other limit!
>>>>>> highly unlikely though.
>>>>>>
>>>>>> please see the atached log.
>>>>>>
>>>>>>
>>> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
>>>>>> # ./gdb ./test_floats
>>>>>> GNU gdb (GDB) 6.8.50.20090803
>>>>>> Copyright (C) 2009 Free Software Foundation,
>>> Inc.
>>>>>> License GPLv3+: GNU GPL version 3 or later
>>> <http://gnu.org/licenses/gpl.html>
>>>>>> This is free software: you are free to change
>>> and
>>>>>> redistribute it.
>>>>>> There is NO WARRANTY, to the extent permitted
>>> by law.
>>>>>> Type "show copying"
>>>>>> and "show warranty" for details.
>>>>>> This GDB was configured as
>>> "i686-pc-linux-gnu".
>>>>>> For bug reporting instructions, please see:
>>>>>> <http://www.gnu.org/software/gdb/bugs/>...
>>>>>> Setting up the environment for debugging gdb.
>>>>>> Function "internal_error" not defined.
>>>>>> Make breakpoint pending on future shared
>>> library load? (y
>>>>>> or [n]) [answered N; input not from terminal]
>>>>>> Function "info_command" not defined.
>>>>>> Make breakpoint pending on future shared
>>> library load? (y
>>>>>> or [n]) [answered N; input not from terminal]
>>>>>>
>>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
>>>>>> Error in sourced command file:
>>>>>> No breakpoint number 0.
>>>>>> (gdb) start
>>>>>> Temporary breakpoint 1 at 0x8048c94: file
>>> ./test_floats.c,
>>>>>> line 196.
>>>>>> Starting program:
>>>>>>
>>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
>>>>>> Temporary breakpoint 1, main () at
>>> ./test_floats.c:196
>>>>>> 196         init_floats();
>>>>>> (gdb) record
>>>>>> (gdb) c
>>>>>> Continuing.
>>>>>> result is 369.438751
>>>>>> result is 10.320001
>>>>>> result is 23.008301
>>>>>> result is 0.000000
>>>>>> result is 10.450000
>>>>>> result is 10.776012
>>>>>> result is 495830.968750
>>>>>> result is -181.778748
>>>>>> result is 12.525923
>>>>>> result is 2.195619
>>>>>> result is 5.055601
>>>>>> result is inf
>>>>>> result is inf
>>>>>> result is -0.988032
>>>>>> result is 0.154251
>>>>>> result is -6.405331
>>>>>> result is 1.537475
>>>>>> The next instruction is syscall exit_group.
>>> It will
>>>>>> make the program exit.  Do you want to stop
>>> the
>>>>>> program?([y] or n) y
>>>>>> Process record: inferior program stopped.
>>>>>>
>>>>>> Program received signal SIGTRAP,
>>> Trace/breakpoint trap.
>>>>>> 0xffffe405 in __kernel_vsyscall ()
>>>>>> (gdb)
>>>>>>
>>>>>> Regards,
>>>>>> Oza.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> From: Hui Zhu <teawater@gmail.com>
>>>>>>> Subject: Re: final
>>> i386.floating.record.patch
>>>>>>> To: "Michael Snyder" <msnyder@vmware.com>
>>>>>>> Cc: "paawan oza" <paawan1982@yahoo.com>,
>>>>>> "gdb-patches@sourceware.org"
>>>>>> <gdb-patches@sourceware.org>,
>>>>>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>>>>>>> Date: Monday, August 17, 2009, 12:06 PM
>>>>>>> Get some error with this patch.
>>>>>>> cat fp.c
>>>>>>> #include <stdio.h>
>>>>>>> #include <math.h>
>>>>>>> #include <stdlib.h>
>>>>>>>
>>>>>>> /* the test intends to test following
>>> insns.
>>>>>>> flds faddp fstps fstpl fldl fxch fabs
>>> fdivrp fmulp
>>>>>> fsubrp
>>>>>>> fucomp fnstsw fsqrt
>>>>>>> fchs f2xm1 fyl2x fxtract fprem1 fld
>>> fdecstp fld1
>>>>>> fldl2t
>>>>>>> fldl2e FLDPI
>>>>>>> FLDLG2 FLDLN2
>>>>>>> FLDZ fincstp ffree fptan fpatan fincstp
>>> fsincos
>>>>>> frndint
>>>>>>> fscale fsin fcos fcmovb
>>>>>>> fcmovbe fcmove fcmovu fcmovnb fcmovnbe
>>> fsave frstor
>>>>>> fstsw
>>>>>>> */
>>>>>>>
>>>>>>> float no1,no2,no3,no4,no5,no6,no7;
>>>>>>> double x = 100.345, y = 25.7789;
>>>>>>> long double ldx =
>>> 88888888888888888888.88, ldy =
>>>>>>> 9999999999999999999.99;
>>>>>>> float result,resultd,resultld;
>>>>>>> float *float_memory;
>>>>>>>
>>>>>>> /* initialization of floats */
>>>>>>> void init_floats()
>>>>>>> {
>>>>>>>  no1 = 10.45;
>>>>>>>  no2 = 20.77;
>>>>>>>  no3 = 156.89874646;
>>>>>>>  no4 = 14.56;
>>>>>>>  no5 = 11.11;
>>>>>>>  no6 = 66.77;
>>>>>>>  no7 = 88.88;
>>>>>>>  float_memory = malloc(sizeof(float) *
>>> 4);
>>>>>>>  *float_memory = 256.256;
>>>>>>>  *(float_memory + 1) = 356.356;
>>>>>>>  *(float_memory + 2) = 456.456;
>>>>>>>  *(float_memory + 3) = 556.556;
>>>>>>> }
>>>>>>>
>>>>>>> /* marks FPU stack as empty */
>>>>>>> void empty_fpu_stack()
>>>>>>> {
>>>>>>>  asm ("ffree %st(1) \n\t"
>>>>>>>       "ffree %st(2) \n\t"
>>>>>>>       "ffree %st(3) \n\t"
>>>>>>>       "ffree %st(4) \n\t"
>>>>>>>       "ffree %st(5) \n\t"
>>>>>>>       "ffree %st(6) \n\t"
>>>>>>>       "ffree %st(7)");
>>>>>>> }
>>>>>>>
>>>>>>> /* tests floating point arithmatic */
>>>>>>> void test_arith_floats()
>>>>>>> {
>>>>>>>  result = no1 + no2 + no3 + no4 + no5 +
>>> no6 +
>>>>>> no7;
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = fmodf(no2,no1);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  resultd = fmod(x,y);
>>>>>>>  printf("result is %f\n",resultd);
>>>>>>>
>>>>>>>  resultld = fmodl(ldy,ldy);
>>>>>>>  printf("result is %f\n",resultld);
>>>>>>>
>>>>>>>  result = fabsf(no1);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = no3 / no4;
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = no1 * no2 * no3 * no4;
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = no1 - no2 - no3 - no4;
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fchs");
>>>>>>>
>>>>>>>  /* test for f2xm1 */
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("f2xm1");
>>>>>>>
>>>>>>>  asm ("fyl2x");
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fxtract");
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fprem1");
>>>>>>>
>>>>>>>  /* decrement fpu stack pointer only
>>> status
>>>>>> register should
>>>>>>> get affected */
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>
>>>>>>>  empty_fpu_stack();
>>>>>>>
>>>>>>>  asm ("fld1");
>>>>>>>  asm ("fldl2t");
>>>>>>>  asm ("fldl2e");
>>>>>>>  asm ("fldpi");
>>>>>>>  asm ("fldlg2");
>>>>>>>  asm ("fldln2");
>>>>>>>  asm ("fldz");
>>>>>>>
>>>>>>>  empty_fpu_stack();
>>>>>>>  /* finishing emptying the stack */
>>>>>>>
>>>>>>>  result = sqrt(no3);
>>>>>>>  printf("result is %f\n",result);
>>>>>>> }
>>>>>>>
>>>>>>> void test_log_exp_floats()
>>>>>>> {
>>>>>>>  result = log10(no3);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = log(no3);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = exp10(no3);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = exp(no3);
>>>>>>>  printf("result is %f\n",result);
>>>>>>> }
>>>>>>>
>>>>>>> void test_trigo_floats()
>>>>>>> {
>>>>>>>  result = sin(30);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = cos(30);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = tan(30);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  result = atan(30);
>>>>>>>  printf("result is %f\n",result);
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fptan");
>>>>>>>
>>>>>>>  /* changes st1 and popping register
>>> stack */
>>>>>>>  asm ("fpatan");
>>>>>>>
>>>>>>>  asm("fincstp");
>>>>>>>  asm ("fld %0" : :"m"(float_memory));
>>>>>>>  asm ("fsincos");
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("frndint");
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fld %0" :
>>> :"m"(*(float_memory+1)));
>>>>>>>  asm ("fscale");
>>>>>>>
>>>>>>>  empty_fpu_stack();
>>>>>>>
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fsin");
>>>>>>>  asm ("fcos");
>>>>>>>
>>>>>>>  /* currently we assume condition likely
>>> and
>>>>>> always record
>>>>>>> the registers
>>>>>>>  code could be optimized only if the
>>> flag is set
>>>>>> then
>>>>>>> record */
>>>>>>>  asm ("fld %0" : :"m"(*float_memory));
>>>>>>>  asm ("fld %0" :
>>> :"m"(*(float_memory+1)));
>>>>>>>  asm ("fcmovb %st(1), %st");
>>>>>>>  asm ("fcmovbe %st(1), %st");
>>>>>>>  asm ("fcmove %st(1), %st");
>>>>>>>  asm ("fcmovu %st(1), %st");
>>>>>>>  asm ("fcmovnb %st(1), %st");
>>>>>>>  asm ("fcmovnbe %st(1), %st");
>>>>>>>
>>>>>>>  empty_fpu_stack();
>>>>>>>  /* finished emtyping the stack */
>>>>>>> }
>>>>>>>
>>>>>>> void test_compare_floats()
>>>>>>> {
>>>>>>>    ldy = 88888888888888888888.88;
>>>>>>>    if (ldx == ldy)
>>>>>>>      ldy =
>>>>>>> 7777777777777777777777777777.777;
>>>>>>>    else
>>>>>>>      ldy =
>>>>>>> 666666666666666666666666666.666;
>>>>>>> }
>>>>>>>
>>>>>>> /* test loading and saving of FPU
>>> environment */
>>>>>>> void test_fpu_env()
>>>>>>> {
>>>>>>>  asm ("fsave %0" : "=m"(*float_memory) :
>>> );
>>>>>>>  asm ("frstor %0" : :
>>> "m"(*float_memory));
>>>>>>>  asm ("fstsw %ax");
>>>>>>> }
>>>>>>>
>>>>>>> int main()
>>>>>>> {
>>>>>>>    init_floats();
>>>>>>>    test_arith_floats();
>>>>>>>    test_log_exp_floats();
>>>>>>>    test_trigo_floats();
>>>>>>>    test_compare_floats();
>>>>>>>    test_fpu_env();
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ./gdb ./a.out
>>>>>>> GNU gdb (GDB) 6.8.50.20090817-cvs
>>>>>>> Copyright (C) 2009 Free Software
>>> Foundation, Inc.
>>>>>>> License GPLv3+: GNU GPL version 3 or
>>> later <http://gnu.org/licenses/gpl.html>
>>>>>>> This is free software: you are free to
>>> change and
>>>>>>> redistribute it.
>>>>>>> There is NO WARRANTY, to the extent
>>> permitted by
>>>>>> law.
>>>>>>> Type "show copying"
>>>>>>> and "show warranty" for details.
>>>>>>> This GDB was configured as
>>> "i686-pc-linux-gnu".
>>>>>>> For bug reporting instructions, please
>>> see:
>>>>>>> <http://www.gnu.org/software/gdb/bugs/>...
>>>>>>> Setting up the environment for debugging
>>> gdb.
>>>>>>> Function "internal_error" not defined.
>>>>>>> Make breakpoint pending on future shared
>>> library load?
>>>>>> (y
>>>>>>> or [n])
>>>>>>> [answered N; input not from terminal]
>>>>>>> Function "info_command" not defined.
>>>>>>> Make breakpoint pending on future shared
>>> library load?
>>>>>> (y
>>>>>>> or [n])
>>>>>>> [answered N; input not from terminal]
>>>>>>> /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
>>> Error in
>>>>>> sourced
>>>>>>> command file:
>>>>>>> No breakpoint number 0.
>>>>>>> (gdb) start
>>>>>>> During symbol reading, DW_AT_name missing
>>> from
>>>>>>> DW_TAG_base_type.
>>>>>>> Temporary breakpoint 1 at 0x8048c74: file
>>> fp.c, line
>>>>>> 196.
>>>>>>> Starting program:
>>> /home/teawater/gdb/bgdbno/gdb/a.out
>>>>>>> Temporary breakpoint 1, main () at
>>> fp.c:196
>>>>>>> 196       init_floats();
>>>>>>> (gdb) record
>>>>>>> (gdb) c
>>>>>>> Continuing.
>>>>>>> ../../src/gdb/utils.c:1200:
>>> internal-error: virtual
>>>>>> memory
>>>>>>> exhausted.
>>>>>>> A problem internal to GDB has been
>>> detected,
>>>>>>> further debugging may prove unreliable.
>>>>>>> Quit this debugging session? (y or n) n
>>>>>>> ../../src/gdb/utils.c:1200:
>>> internal-error: virtual
>>>>>> memory
>>>>>>> exhausted.
>>>>>>> A problem internal to GDB has been
>>> detected,
>>>>>>> further debugging may prove unreliable.
>>>>>>> Create a core file of GDB? (y or n) n
>>>>>>>
>>>>>>> Program received signal SIGTRAP,
>>> Trace/breakpoint
>>>>>> trap.
>>>>>>> 0xb7eba9bc in memcpy () from
>>>>>> /lib/tls/i686/cmov/libc.so.6
>>>>>>> (gdb) quit
>>>>>>> A debugging session is active.
>>>>>>>
>>>>>>>     Inferior 1 [process 15657] will
>>> be
>>>>>>> killed.
>>>>>>>
>>>>>>> Quit anyway? (y or n) y
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Hui
>>>>>>>
>>>>>>> On Mon, Aug 17, 2009 at 05:16, Michael
>>> Snyder<msnyder@vmware.com>
>>>>>>> wrote:
>>>>>>>> paawan oza wrote:
>>>>>>>>> Hi Hui & Michael,
>>>>>>>>> Now we revert status registers
>>> also.
>>>>>>>>> please find the patch attached.
>>>>>>>>> I am sorry, if I am not pasting
>>> the patch in
>>>>>>> email-body due to tabs&spaces
>>>>>>>>> problem faced by Michael last
>>> time.
>>>>>>>>> Regards,
>>>>>>>>> Oza.
>>>>>>>> Looking good!
>>>>>>>>
>>>>>>>> There were some conflicts between
>>> your changes
>>>>>> and a
>>>>>>> check-in that
>>>>>>>> happened after your submission  --
>>>  I've taken
>>>>>> the
>>>>>>> liberty of merging
>>>>>>>> your changes with the cvs head,
>>> fixing up the
>>>>>>> conflicts.  Hope you
>>>>>>>> don't mind  --  merged patch
>>> attached.
>>>>>>>> I'll review your tests next.
>>>>>>>>
>>>>>>>> Can you write up a change log entry
>>> for this
>>>>>> patch?
>>>>>>>> Hui, Mark, any more comments?
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Michael
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>
>>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-21 16:59 paawan oza
@ 2009-08-23  1:32 ` Hui Zhu
  2009-08-23  3:00   ` Michael Snyder
  2009-09-09  0:19 ` Michael Snyder
  2009-12-10  7:55 ` Hui Zhu
  2 siblings, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-08-23  1:32 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches, Mark Kettenis

I think this patch is OK.  How do we continue?

Thanks,
Hui

On Sat, Aug 22, 2009 at 00:30, paawan oza<paawan1982@yahoo.com> wrote:
> Hu Hui,
> please find the ChageLog and floating point patch attached as you suggested.
> Sorry for not pasting it in email-body becasue of space and tabs issues.
> Do we need to update wiki?
> Regards,
> Oza.
>
> --- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> Date: Wednesday, August 19, 2009, 7:47 AM
>> Oops, this is not the bug in fp
>> patch.  Sorry for it.
>>
>> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
>>
>> Everything is OK.
>>
>> I post a new patch that remove space in the tail.
>> I think you need write a changelog.  You can get a
>> example from
>> src/ChangeLog.  Please Let each line doesn't bigger
>> than 72.
>>
>> Thanks,
>> Hui
>>
>> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
>> wrote:
>> > Could you try cvs-head?
>> >
>> > On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >> Hi,
>> >>
>> >> Another analysis and observation is:
>> >>
>> >> I used gdb-6.8.50.20090803 and everything seemed
>> okay.
>> >> Hui used gdb-6.8.50.20090817 and patch was still
>> the same and gdb threw these error.
>> >> was there any thing major changed in gdb ?
>> >>
>> >> and gdb throws error in
>> >> ../../src/gdb/utils.c:1200:
>> >>
>> >> which looks like somebody has allocated memory too
>> much or something has gone wrong in error checking.
>> >>
>> >>
>> >> the floating-point-patch is still the same, if it
>> works fine with gdb-6.8.50.20090803, it is high unlikely
>> that why should it throw memory allocation error with
>> gdb-6.8.50.20090817 (unless system is dangerously low in
>> virtual memory, swap space is full).
>> >>
>> >> Regards,
>> >> Oza.
>> >>
>> >>
>> >>
>> >> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
>> wrote:
>> >>
>> >>> From: paawan oza <paawan1982@yahoo.com>
>> >>> Subject: Re: final i386.floating.record.patch
>> >>> To: "Michael Snyder" <msnyder@vmware.com>,
>> "Hui Zhu" <teawater@gmail.com>
>> >>> Cc: "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>,
>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> >>> Date: Monday, August 17, 2009, 9:40 PM
>> >>> Hi Hui,
>> >>>
>> >>> I test the same and it seems working fine.
>> Another thing I
>> >>> observe is, vertual memory is low problem and
>> may be gdb's
>> >>> virtual address space gets exhausted or any
>> other limit!
>> >>> highly unlikely though.
>> >>>
>> >>> please see the atached log.
>> >>>
>> >>>
>> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
>> >>> # ./gdb ./test_floats
>> >>> GNU gdb (GDB) 6.8.50.20090803
>> >>> Copyright (C) 2009 Free Software Foundation,
>> Inc.
>> >>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> >>> This is free software: you are free to change
>> and
>> >>> redistribute it.
>> >>> There is NO WARRANTY, to the extent permitted
>> by law.
>> >>> Type "show copying"
>> >>> and "show warranty" for details.
>> >>> This GDB was configured as
>> "i686-pc-linux-gnu".
>> >>> For bug reporting instructions, please see:
>> >>> <http://www.gnu.org/software/gdb/bugs/>...
>> >>> Setting up the environment for debugging gdb.
>> >>> Function "internal_error" not defined.
>> >>> Make breakpoint pending on future shared
>> library load? (y
>> >>> or [n]) [answered N; input not from terminal]
>> >>> Function "info_command" not defined.
>> >>> Make breakpoint pending on future shared
>> library load? (y
>> >>> or [n]) [answered N; input not from terminal]
>> >>>
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
>> >>> Error in sourced command file:
>> >>> No breakpoint number 0.
>> >>> (gdb) start
>> >>> Temporary breakpoint 1 at 0x8048c94: file
>> ./test_floats.c,
>> >>> line 196.
>> >>> Starting program:
>> >>>
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
>> >>>
>> >>> Temporary breakpoint 1, main () at
>> ./test_floats.c:196
>> >>> 196         init_floats();
>> >>> (gdb) record
>> >>> (gdb) c
>> >>> Continuing.
>> >>> result is 369.438751
>> >>> result is 10.320001
>> >>> result is 23.008301
>> >>> result is 0.000000
>> >>> result is 10.450000
>> >>> result is 10.776012
>> >>> result is 495830.968750
>> >>> result is -181.778748
>> >>> result is 12.525923
>> >>> result is 2.195619
>> >>> result is 5.055601
>> >>> result is inf
>> >>> result is inf
>> >>> result is -0.988032
>> >>> result is 0.154251
>> >>> result is -6.405331
>> >>> result is 1.537475
>> >>> The next instruction is syscall exit_group.
>> It will
>> >>> make the program exit.  Do you want to stop
>> the
>> >>> program?([y] or n) y
>> >>> Process record: inferior program stopped.
>> >>>
>> >>> Program received signal SIGTRAP,
>> Trace/breakpoint trap.
>> >>> 0xffffe405 in __kernel_vsyscall ()
>> >>> (gdb)
>> >>>
>> >>> Regards,
>> >>> Oza.
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
>> >>> wrote:
>> >>>
>> >>> > From: Hui Zhu <teawater@gmail.com>
>> >>> > Subject: Re: final
>> i386.floating.record.patch
>> >>> > To: "Michael Snyder" <msnyder@vmware.com>
>> >>> > Cc: "paawan oza" <paawan1982@yahoo.com>,
>> >>> "gdb-patches@sourceware.org"
>> >>> <gdb-patches@sourceware.org>,
>> >>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> >>> > Date: Monday, August 17, 2009, 12:06 PM
>> >>> > Get some error with this patch.
>> >>> > cat fp.c
>> >>> > #include <stdio.h>
>> >>> > #include <math.h>
>> >>> > #include <stdlib.h>
>> >>> >
>> >>> > /* the test intends to test following
>> insns.
>> >>> > flds faddp fstps fstpl fldl fxch fabs
>> fdivrp fmulp
>> >>> fsubrp
>> >>> > fucomp fnstsw fsqrt
>> >>> > fchs f2xm1 fyl2x fxtract fprem1 fld
>> fdecstp fld1
>> >>> fldl2t
>> >>> > fldl2e FLDPI
>> >>> > FLDLG2 FLDLN2
>> >>> > FLDZ fincstp ffree fptan fpatan fincstp
>> fsincos
>> >>> frndint
>> >>> > fscale fsin fcos fcmovb
>> >>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe
>> fsave frstor
>> >>> fstsw
>> >>> > */
>> >>> >
>> >>> > float no1,no2,no3,no4,no5,no6,no7;
>> >>> > double x = 100.345, y = 25.7789;
>> >>> > long double ldx =
>> 88888888888888888888.88, ldy =
>> >>> > 9999999999999999999.99;
>> >>> > float result,resultd,resultld;
>> >>> > float *float_memory;
>> >>> >
>> >>> > /* initialization of floats */
>> >>> > void init_floats()
>> >>> > {
>> >>> >  no1 = 10.45;
>> >>> >  no2 = 20.77;
>> >>> >  no3 = 156.89874646;
>> >>> >  no4 = 14.56;
>> >>> >  no5 = 11.11;
>> >>> >  no6 = 66.77;
>> >>> >  no7 = 88.88;
>> >>> >  float_memory = malloc(sizeof(float) *
>> 4);
>> >>> >  *float_memory = 256.256;
>> >>> >  *(float_memory + 1) = 356.356;
>> >>> >  *(float_memory + 2) = 456.456;
>> >>> >  *(float_memory + 3) = 556.556;
>> >>> > }
>> >>> >
>> >>> > /* marks FPU stack as empty */
>> >>> > void empty_fpu_stack()
>> >>> > {
>> >>> >  asm ("ffree %st(1) \n\t"
>> >>> >       "ffree %st(2) \n\t"
>> >>> >       "ffree %st(3) \n\t"
>> >>> >       "ffree %st(4) \n\t"
>> >>> >       "ffree %st(5) \n\t"
>> >>> >       "ffree %st(6) \n\t"
>> >>> >       "ffree %st(7)");
>> >>> > }
>> >>> >
>> >>> > /* tests floating point arithmatic */
>> >>> > void test_arith_floats()
>> >>> > {
>> >>> >  result = no1 + no2 + no3 + no4 + no5 +
>> no6 +
>> >>> no7;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = fmodf(no2,no1);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  resultd = fmod(x,y);
>> >>> >  printf("result is %f\n",resultd);
>> >>> >
>> >>> >  resultld = fmodl(ldy,ldy);
>> >>> >  printf("result is %f\n",resultld);
>> >>> >
>> >>> >  result = fabsf(no1);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no3 / no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no1 * no2 * no3 * no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = no1 - no2 - no3 - no4;
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fchs");
>> >>> >
>> >>> >  /* test for f2xm1 */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("f2xm1");
>> >>> >
>> >>> >  asm ("fyl2x");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fxtract");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fprem1");
>> >>> >
>> >>> >  /* decrement fpu stack pointer only
>> status
>> >>> register should
>> >>> > get affected */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >
>> >>> >  asm ("fld1");
>> >>> >  asm ("fldl2t");
>> >>> >  asm ("fldl2e");
>> >>> >  asm ("fldpi");
>> >>> >  asm ("fldlg2");
>> >>> >  asm ("fldln2");
>> >>> >  asm ("fldz");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >  /* finishing emptying the stack */
>> >>> >
>> >>> >  result = sqrt(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> > }
>> >>> >
>> >>> > void test_log_exp_floats()
>> >>> > {
>> >>> >  result = log10(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = log(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = exp10(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = exp(no3);
>> >>> >  printf("result is %f\n",result);
>> >>> > }
>> >>> >
>> >>> > void test_trigo_floats()
>> >>> > {
>> >>> >  result = sin(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = cos(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = tan(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  result = atan(30);
>> >>> >  printf("result is %f\n",result);
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fptan");
>> >>> >
>> >>> >  /* changes st1 and popping register
>> stack */
>> >>> >  asm ("fpatan");
>> >>> >
>> >>> >  asm("fincstp");
>> >>> >  asm ("fld %0" : :"m"(float_memory));
>> >>> >  asm ("fsincos");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("frndint");
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >>> >  asm ("fscale");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fsin");
>> >>> >  asm ("fcos");
>> >>> >
>> >>> >  /* currently we assume condition likely
>> and
>> >>> always record
>> >>> > the registers
>> >>> >  code could be optimized only if the
>> flag is set
>> >>> then
>> >>> > record */
>> >>> >  asm ("fld %0" : :"m"(*float_memory));
>> >>> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >>> >  asm ("fcmovb %st(1), %st");
>> >>> >  asm ("fcmovbe %st(1), %st");
>> >>> >  asm ("fcmove %st(1), %st");
>> >>> >  asm ("fcmovu %st(1), %st");
>> >>> >  asm ("fcmovnb %st(1), %st");
>> >>> >  asm ("fcmovnbe %st(1), %st");
>> >>> >
>> >>> >  empty_fpu_stack();
>> >>> >  /* finished emtyping the stack */
>> >>> > }
>> >>> >
>> >>> > void test_compare_floats()
>> >>> > {
>> >>> >    ldy = 88888888888888888888.88;
>> >>> >    if (ldx == ldy)
>> >>> >      ldy =
>> >>> > 7777777777777777777777777777.777;
>> >>> >    else
>> >>> >      ldy =
>> >>> > 666666666666666666666666666.666;
>> >>> > }
>> >>> >
>> >>> > /* test loading and saving of FPU
>> environment */
>> >>> > void test_fpu_env()
>> >>> > {
>> >>> >  asm ("fsave %0" : "=m"(*float_memory) :
>> );
>> >>> >  asm ("frstor %0" : :
>> "m"(*float_memory));
>> >>> >  asm ("fstsw %ax");
>> >>> > }
>> >>> >
>> >>> > int main()
>> >>> > {
>> >>> >    init_floats();
>> >>> >    test_arith_floats();
>> >>> >    test_log_exp_floats();
>> >>> >    test_trigo_floats();
>> >>> >    test_compare_floats();
>> >>> >    test_fpu_env();
>> >>> > }
>> >>> >
>> >>> >
>> >>> >
>> >>> > ./gdb ./a.out
>> >>> > GNU gdb (GDB) 6.8.50.20090817-cvs
>> >>> > Copyright (C) 2009 Free Software
>> Foundation, Inc.
>> >>> > License GPLv3+: GNU GPL version 3 or
>> later <http://gnu.org/licenses/gpl.html>
>> >>> > This is free software: you are free to
>> change and
>> >>> > redistribute it.
>> >>> > There is NO WARRANTY, to the extent
>> permitted by
>> >>> law.
>> >>> > Type "show copying"
>> >>> > and "show warranty" for details.
>> >>> > This GDB was configured as
>> "i686-pc-linux-gnu".
>> >>> > For bug reporting instructions, please
>> see:
>> >>> > <http://www.gnu.org/software/gdb/bugs/>...
>> >>> > Setting up the environment for debugging
>> gdb.
>> >>> > Function "internal_error" not defined.
>> >>> > Make breakpoint pending on future shared
>> library load?
>> >>> (y
>> >>> > or [n])
>> >>> > [answered N; input not from terminal]
>> >>> > Function "info_command" not defined.
>> >>> > Make breakpoint pending on future shared
>> library load?
>> >>> (y
>> >>> > or [n])
>> >>> > [answered N; input not from terminal]
>> >>> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
>> Error in
>> >>> sourced
>> >>> > command file:
>> >>> > No breakpoint number 0.
>> >>> > (gdb) start
>> >>> > During symbol reading, DW_AT_name missing
>> from
>> >>> > DW_TAG_base_type.
>> >>> > Temporary breakpoint 1 at 0x8048c74: file
>> fp.c, line
>> >>> 196.
>> >>> > Starting program:
>> /home/teawater/gdb/bgdbno/gdb/a.out
>> >>> >
>> >>> > Temporary breakpoint 1, main () at
>> fp.c:196
>> >>> > 196       init_floats();
>> >>> > (gdb) record
>> >>> > (gdb) c
>> >>> > Continuing.
>> >>> > ../../src/gdb/utils.c:1200:
>> internal-error: virtual
>> >>> memory
>> >>> > exhausted.
>> >>> > A problem internal to GDB has been
>> detected,
>> >>> > further debugging may prove unreliable.
>> >>> > Quit this debugging session? (y or n) n
>> >>> > ../../src/gdb/utils.c:1200:
>> internal-error: virtual
>> >>> memory
>> >>> > exhausted.
>> >>> > A problem internal to GDB has been
>> detected,
>> >>> > further debugging may prove unreliable.
>> >>> > Create a core file of GDB? (y or n) n
>> >>> >
>> >>> > Program received signal SIGTRAP,
>> Trace/breakpoint
>> >>> trap.
>> >>> > 0xb7eba9bc in memcpy () from
>> >>> /lib/tls/i686/cmov/libc.so.6
>> >>> > (gdb) quit
>> >>> > A debugging session is active.
>> >>> >
>> >>> >     Inferior 1 [process 15657] will
>> be
>> >>> > killed.
>> >>> >
>> >>> > Quit anyway? (y or n) y
>> >>> >
>> >>> >
>> >>> > Thanks,
>> >>> > Hui
>> >>> >
>> >>> > On Mon, Aug 17, 2009 at 05:16, Michael
>> Snyder<msnyder@vmware.com>
>> >>> > wrote:
>> >>> > > paawan oza wrote:
>> >>> > >>
>> >>> > >> Hi Hui & Michael,
>> >>> > >> Now we revert status registers
>> also.
>> >>> > >> please find the patch attached.
>> >>> > >> I am sorry, if I am not pasting
>> the patch in
>> >>> > email-body due to tabs&spaces
>> >>> > >> problem faced by Michael last
>> time.
>> >>> > >> Regards,
>> >>> > >> Oza.
>> >>> > >
>> >>> > > Looking good!
>> >>> > >
>> >>> > > There were some conflicts between
>> your changes
>> >>> and a
>> >>> > check-in that
>> >>> > > happened after your submission  --
>>  I've taken
>> >>> the
>> >>> > liberty of merging
>> >>> > > your changes with the cvs head,
>> fixing up the
>> >>> > conflicts.  Hope you
>> >>> > > don't mind  --  merged patch
>> attached.
>> >>> > >
>> >>> > > I'll review your tests next.
>> >>> > >
>> >>> > > Can you write up a change log entry
>> for this
>> >>> patch?
>> >>> > >
>> >>> > > Hui, Mark, any more comments?
>> >>> > >
>> >>> > > Cheers,
>> >>> > > Michael
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >>
>> >
>>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
@ 2009-08-21 16:59 paawan oza
  2009-08-23  1:32 ` Hui Zhu
                   ` (2 more replies)
  0 siblings, 3 replies; 40+ messages in thread
From: paawan oza @ 2009-08-21 16:59 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches, Mark Kettenis

[-- Attachment #1: Type: text/plain, Size: 15616 bytes --]

Hu Hui,
please find the ChageLog and floating point patch attached as you suggested.
Sorry for not pasting it in email-body becasue of space and tabs issues.
Do we need to update wiki?
Regards,
Oza.

--- On Wed, 8/19/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
> Date: Wednesday, August 19, 2009, 7:47 AM
> Oops, this is not the bug in fp
> patch.  Sorry for it.
> 
> After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html
> 
> Everything is OK.
> 
> I post a new patch that remove space in the tail.
> I think you need write a changelog.  You can get a
> example from
> src/ChangeLog.  Please Let each line doesn't bigger
> than 72.
> 
> Thanks,
> Hui
> 
> On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com>
> wrote:
> > Could you try cvs-head?
> >
> > On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com>
> wrote:
> >> Hi,
> >>
> >> Another analysis and observation is:
> >>
> >> I used gdb-6.8.50.20090803 and everything seemed
> okay.
> >> Hui used gdb-6.8.50.20090817 and patch was still
> the same and gdb threw these error.
> >> was there any thing major changed in gdb ?
> >>
> >> and gdb throws error in
> >> ../../src/gdb/utils.c:1200:
> >>
> >> which looks like somebody has allocated memory too
> much or something has gone wrong in error checking.
> >>
> >>
> >> the floating-point-patch is still the same, if it
> works fine with gdb-6.8.50.20090803, it is high unlikely
> that why should it throw memory allocation error with
> gdb-6.8.50.20090817 (unless system is dangerously low in
> virtual memory, swap space is full).
> >>
> >> Regards,
> >> Oza.
> >>
> >>
> >>
> >> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com>
> wrote:
> >>
> >>> From: paawan oza <paawan1982@yahoo.com>
> >>> Subject: Re: final i386.floating.record.patch
> >>> To: "Michael Snyder" <msnyder@vmware.com>,
> "Hui Zhu" <teawater@gmail.com>
> >>> Cc: "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>> Date: Monday, August 17, 2009, 9:40 PM
> >>> Hi Hui,
> >>>
> >>> I test the same and it seems working fine.
> Another thing I
> >>> observe is, vertual memory is low problem and
> may be gdb's
> >>> virtual address space gets exhausted or any
> other limit!
> >>> highly unlikely though.
> >>>
> >>> please see the atached log.
> >>>
> >>>
> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
> >>> # ./gdb ./test_floats
> >>> GNU gdb (GDB) 6.8.50.20090803
> >>> Copyright (C) 2009 Free Software Foundation,
> Inc.
> >>> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
> >>> This is free software: you are free to change
> and
> >>> redistribute it.
> >>> There is NO WARRANTY, to the extent permitted
> by law.
> >>> Type "show copying"
> >>> and "show warranty" for details.
> >>> This GDB was configured as
> "i686-pc-linux-gnu".
> >>> For bug reporting instructions, please see:
> >>> <http://www.gnu.org/software/gdb/bugs/>...
> >>> Setting up the environment for debugging gdb.
> >>> Function "internal_error" not defined.
> >>> Make breakpoint pending on future shared
> library load? (y
> >>> or [n]) [answered N; input not from terminal]
> >>> Function "info_command" not defined.
> >>> Make breakpoint pending on future shared
> library load? (y
> >>> or [n]) [answered N; input not from terminal]
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
> >>> Error in sourced command file:
> >>> No breakpoint number 0.
> >>> (gdb) start
> >>> Temporary breakpoint 1 at 0x8048c94: file
> ./test_floats.c,
> >>> line 196.
> >>> Starting program:
> >>>
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
> >>>
> >>> Temporary breakpoint 1, main () at
> ./test_floats.c:196
> >>> 196         init_floats();
> >>> (gdb) record
> >>> (gdb) c
> >>> Continuing.
> >>> result is 369.438751
> >>> result is 10.320001
> >>> result is 23.008301
> >>> result is 0.000000
> >>> result is 10.450000
> >>> result is 10.776012
> >>> result is 495830.968750
> >>> result is -181.778748
> >>> result is 12.525923
> >>> result is 2.195619
> >>> result is 5.055601
> >>> result is inf
> >>> result is inf
> >>> result is -0.988032
> >>> result is 0.154251
> >>> result is -6.405331
> >>> result is 1.537475
> >>> The next instruction is syscall exit_group. 
> It will
> >>> make the program exit.  Do you want to stop
> the
> >>> program?([y] or n) y
> >>> Process record: inferior program stopped.
> >>>
> >>> Program received signal SIGTRAP,
> Trace/breakpoint trap.
> >>> 0xffffe405 in __kernel_vsyscall ()
> >>> (gdb)
> >>>
> >>> Regards,
> >>> Oza.
> >>>
> >>>
> >>>
> >>>
> >>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
> >>> wrote:
> >>>
> >>> > From: Hui Zhu <teawater@gmail.com>
> >>> > Subject: Re: final
> i386.floating.record.patch
> >>> > To: "Michael Snyder" <msnyder@vmware.com>
> >>> > Cc: "paawan oza" <paawan1982@yahoo.com>,
> >>> "gdb-patches@sourceware.org"
> >>> <gdb-patches@sourceware.org>,
> >>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> >>> > Date: Monday, August 17, 2009, 12:06 PM
> >>> > Get some error with this patch.
> >>> > cat fp.c
> >>> > #include <stdio.h>
> >>> > #include <math.h>
> >>> > #include <stdlib.h>
> >>> >
> >>> > /* the test intends to test following
> insns.
> >>> > flds faddp fstps fstpl fldl fxch fabs
> fdivrp fmulp
> >>> fsubrp
> >>> > fucomp fnstsw fsqrt
> >>> > fchs f2xm1 fyl2x fxtract fprem1 fld
> fdecstp fld1
> >>> fldl2t
> >>> > fldl2e FLDPI
> >>> > FLDLG2 FLDLN2
> >>> > FLDZ fincstp ffree fptan fpatan fincstp
> fsincos
> >>> frndint
> >>> > fscale fsin fcos fcmovb
> >>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe
> fsave frstor
> >>> fstsw
> >>> > */
> >>> >
> >>> > float no1,no2,no3,no4,no5,no6,no7;
> >>> > double x = 100.345, y = 25.7789;
> >>> > long double ldx =
> 88888888888888888888.88, ldy =
> >>> > 9999999999999999999.99;
> >>> > float result,resultd,resultld;
> >>> > float *float_memory;
> >>> >
> >>> > /* initialization of floats */
> >>> > void init_floats()
> >>> > {
> >>> >  no1 = 10.45;
> >>> >  no2 = 20.77;
> >>> >  no3 = 156.89874646;
> >>> >  no4 = 14.56;
> >>> >  no5 = 11.11;
> >>> >  no6 = 66.77;
> >>> >  no7 = 88.88;
> >>> >  float_memory = malloc(sizeof(float) *
> 4);
> >>> >  *float_memory = 256.256;
> >>> >  *(float_memory + 1) = 356.356;
> >>> >  *(float_memory + 2) = 456.456;
> >>> >  *(float_memory + 3) = 556.556;
> >>> > }
> >>> >
> >>> > /* marks FPU stack as empty */
> >>> > void empty_fpu_stack()
> >>> > {
> >>> >  asm ("ffree %st(1) \n\t"
> >>> >       "ffree %st(2) \n\t"
> >>> >       "ffree %st(3) \n\t"
> >>> >       "ffree %st(4) \n\t"
> >>> >       "ffree %st(5) \n\t"
> >>> >       "ffree %st(6) \n\t"
> >>> >       "ffree %st(7)");
> >>> > }
> >>> >
> >>> > /* tests floating point arithmatic */
> >>> > void test_arith_floats()
> >>> > {
> >>> >  result = no1 + no2 + no3 + no4 + no5 +
> no6 +
> >>> no7;
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = fmodf(no2,no1);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  resultd = fmod(x,y);
> >>> >  printf("result is %f\n",resultd);
> >>> >
> >>> >  resultld = fmodl(ldy,ldy);
> >>> >  printf("result is %f\n",resultld);
> >>> >
> >>> >  result = fabsf(no1);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = no3 / no4;
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = no1 * no2 * no3 * no4;
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = no1 - no2 - no3 - no4;
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fchs");
> >>> >
> >>> >  /* test for f2xm1 */
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("f2xm1");
> >>> >
> >>> >  asm ("fyl2x");
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fxtract");
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fprem1");
> >>> >
> >>> >  /* decrement fpu stack pointer only
> status
> >>> register should
> >>> > get affected */
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >
> >>> >  empty_fpu_stack();
> >>> >
> >>> >  asm ("fld1");
> >>> >  asm ("fldl2t");
> >>> >  asm ("fldl2e");
> >>> >  asm ("fldpi");
> >>> >  asm ("fldlg2");
> >>> >  asm ("fldln2");
> >>> >  asm ("fldz");
> >>> >
> >>> >  empty_fpu_stack();
> >>> >  /* finishing emptying the stack */
> >>> >
> >>> >  result = sqrt(no3);
> >>> >  printf("result is %f\n",result);
> >>> > }
> >>> >
> >>> > void test_log_exp_floats()
> >>> > {
> >>> >  result = log10(no3);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = log(no3);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = exp10(no3);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = exp(no3);
> >>> >  printf("result is %f\n",result);
> >>> > }
> >>> >
> >>> > void test_trigo_floats()
> >>> > {
> >>> >  result = sin(30);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = cos(30);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = tan(30);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  result = atan(30);
> >>> >  printf("result is %f\n",result);
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fptan");
> >>> >
> >>> >  /* changes st1 and popping register
> stack */
> >>> >  asm ("fpatan");
> >>> >
> >>> >  asm("fincstp");
> >>> >  asm ("fld %0" : :"m"(float_memory));
> >>> >  asm ("fsincos");
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("frndint");
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fld %0" :
> :"m"(*(float_memory+1)));
> >>> >  asm ("fscale");
> >>> >
> >>> >  empty_fpu_stack();
> >>> >
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fsin");
> >>> >  asm ("fcos");
> >>> >
> >>> >  /* currently we assume condition likely
> and
> >>> always record
> >>> > the registers
> >>> >  code could be optimized only if the
> flag is set
> >>> then
> >>> > record */
> >>> >  asm ("fld %0" : :"m"(*float_memory));
> >>> >  asm ("fld %0" :
> :"m"(*(float_memory+1)));
> >>> >  asm ("fcmovb %st(1), %st");
> >>> >  asm ("fcmovbe %st(1), %st");
> >>> >  asm ("fcmove %st(1), %st");
> >>> >  asm ("fcmovu %st(1), %st");
> >>> >  asm ("fcmovnb %st(1), %st");
> >>> >  asm ("fcmovnbe %st(1), %st");
> >>> >
> >>> >  empty_fpu_stack();
> >>> >  /* finished emtyping the stack */
> >>> > }
> >>> >
> >>> > void test_compare_floats()
> >>> > {
> >>> >    ldy = 88888888888888888888.88;
> >>> >    if (ldx == ldy)
> >>> >      ldy =
> >>> > 7777777777777777777777777777.777;
> >>> >    else
> >>> >      ldy =
> >>> > 666666666666666666666666666.666;
> >>> > }
> >>> >
> >>> > /* test loading and saving of FPU
> environment */
> >>> > void test_fpu_env()
> >>> > {
> >>> >  asm ("fsave %0" : "=m"(*float_memory) :
> );
> >>> >  asm ("frstor %0" : :
> "m"(*float_memory));
> >>> >  asm ("fstsw %ax");
> >>> > }
> >>> >
> >>> > int main()
> >>> > {
> >>> >    init_floats();
> >>> >    test_arith_floats();
> >>> >    test_log_exp_floats();
> >>> >    test_trigo_floats();
> >>> >    test_compare_floats();
> >>> >    test_fpu_env();
> >>> > }
> >>> >
> >>> >
> >>> >
> >>> > ./gdb ./a.out
> >>> > GNU gdb (GDB) 6.8.50.20090817-cvs
> >>> > Copyright (C) 2009 Free Software
> Foundation, Inc.
> >>> > License GPLv3+: GNU GPL version 3 or
> later <http://gnu.org/licenses/gpl.html>
> >>> > This is free software: you are free to
> change and
> >>> > redistribute it.
> >>> > There is NO WARRANTY, to the extent
> permitted by
> >>> law.
> >>> > Type "show copying"
> >>> > and "show warranty" for details.
> >>> > This GDB was configured as
> "i686-pc-linux-gnu".
> >>> > For bug reporting instructions, please
> see:
> >>> > <http://www.gnu.org/software/gdb/bugs/>...
> >>> > Setting up the environment for debugging
> gdb.
> >>> > Function "internal_error" not defined.
> >>> > Make breakpoint pending on future shared
> library load?
> >>> (y
> >>> > or [n])
> >>> > [answered N; input not from terminal]
> >>> > Function "info_command" not defined.
> >>> > Make breakpoint pending on future shared
> library load?
> >>> (y
> >>> > or [n])
> >>> > [answered N; input not from terminal]
> >>> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8:
> Error in
> >>> sourced
> >>> > command file:
> >>> > No breakpoint number 0.
> >>> > (gdb) start
> >>> > During symbol reading, DW_AT_name missing
> from
> >>> > DW_TAG_base_type.
> >>> > Temporary breakpoint 1 at 0x8048c74: file
> fp.c, line
> >>> 196.
> >>> > Starting program:
> /home/teawater/gdb/bgdbno/gdb/a.out
> >>> >
> >>> > Temporary breakpoint 1, main () at
> fp.c:196
> >>> > 196       init_floats();
> >>> > (gdb) record
> >>> > (gdb) c
> >>> > Continuing.
> >>> > ../../src/gdb/utils.c:1200:
> internal-error: virtual
> >>> memory
> >>> > exhausted.
> >>> > A problem internal to GDB has been
> detected,
> >>> > further debugging may prove unreliable.
> >>> > Quit this debugging session? (y or n) n
> >>> > ../../src/gdb/utils.c:1200:
> internal-error: virtual
> >>> memory
> >>> > exhausted.
> >>> > A problem internal to GDB has been
> detected,
> >>> > further debugging may prove unreliable.
> >>> > Create a core file of GDB? (y or n) n
> >>> >
> >>> > Program received signal SIGTRAP,
> Trace/breakpoint
> >>> trap.
> >>> > 0xb7eba9bc in memcpy () from
> >>> /lib/tls/i686/cmov/libc.so.6
> >>> > (gdb) quit
> >>> > A debugging session is active.
> >>> >
> >>> >     Inferior 1 [process 15657] will
> be
> >>> > killed.
> >>> >
> >>> > Quit anyway? (y or n) y
> >>> >
> >>> >
> >>> > Thanks,
> >>> > Hui
> >>> >
> >>> > On Mon, Aug 17, 2009 at 05:16, Michael
> Snyder<msnyder@vmware.com>
> >>> > wrote:
> >>> > > paawan oza wrote:
> >>> > >>
> >>> > >> Hi Hui & Michael,
> >>> > >> Now we revert status registers
> also.
> >>> > >> please find the patch attached.
> >>> > >> I am sorry, if I am not pasting
> the patch in
> >>> > email-body due to tabs&spaces
> >>> > >> problem faced by Michael last
> time.
> >>> > >> Regards,
> >>> > >> Oza.
> >>> > >
> >>> > > Looking good!
> >>> > >
> >>> > > There were some conflicts between
> your changes
> >>> and a
> >>> > check-in that
> >>> > > happened after your submission  --
>  I've taken
> >>> the
> >>> > liberty of merging
> >>> > > your changes with the cvs head,
> fixing up the
> >>> > conflicts.  Hope you
> >>> > > don't mind  --  merged patch
> attached.
> >>> > >
> >>> > > I'll review your tests next.
> >>> > >
> >>> > > Can you write up a change log entry
> for this
> >>> patch?
> >>> > >
> >>> > > Hui, Mark, any more comments?
> >>> > >
> >>> > > Cheers,
> >>> > > Michael
> >>> > >
> >>> > >
> >>> > >
> >>> > >
> >>> > >
> >>> >
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
>


      

[-- Attachment #2: i386.record.float.aug-21.patch --]
[-- Type: application/octet-stream, Size: 14363 bytes --]

---
 i386-tdep.c |  389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 369 insertions(+), 20 deletions(-)

--- a/i386-tdep.c
+++ b/i386-tdep.c
@@ -3196,6 +3196,74 @@ i386_record_push (struct i386_record_s *
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.
+*/
+
+static int i386_record_floats (struct gdbarch *gdbarch,
+                               struct i386_record_s *ir,
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to
+     happen.  Currently we store st0-st7 registers, but we need not store all
+     registers all the time, in future we use ftag register and record only
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	      {
+	      if (record_arch_list_add_reg (ir->regcache, i))
+	        return -1;
+	      }
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  if(I386_SAVE_FPU_ENV != iregnum)
+    {
+    for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+      if (record_arch_list_add_reg (ir->regcache, i))
+        return -1;
+      }
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3214,6 +3282,7 @@ i386_process_record (struct gdbarch *gdb
   ULONGEST tmpulongest;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int rex = 0;
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
@@ -4260,8 +4329,7 @@ reswitch:
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4275,45 +4343,56 @@ reswitch:
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory. */
 	  uint64_t tmpu64;
 
 	  if (i386_record_lea_modrm_addr (&ir, &tmpu64))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+	      /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+	      /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4322,6 +4401,7 @@ reswitch:
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d:
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4330,9 +4410,14 @@ reswitch:
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c:
+            case 0x3d:
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4346,6 +4431,7 @@ reswitch:
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4356,15 +4442,49 @@ reswitch:
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (tmpu64, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (tmpu64, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (tmpu64, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4374,11 +4494,21 @@ reswitch:
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4396,6 +4526,9 @@ reswitch:
 	    case 0x2f:
 	      if (record_arch_list_add_mem (tmpu64, 2))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x1f:
 	    case 0x3e:
@@ -4417,10 +4550,17 @@ reswitch:
 		}
 	      if (record_arch_list_add_mem (tmpu64, 80))
 		return -1;
+	      /* Insn fsave.  */
+	      if (i386_record_floats (gdbarch, &ir,
+				      I386_SAVE_FPU_ENV_REG_STACK))
+		return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (tmpu64, 8))
 		return -1;
+	      /* Insn fistp.  */
+	      if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4429,8 +4569,211 @@ reswitch:
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */
+      else
+        {
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;
+	      break;
+	    case 0xd9:
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      /* If only st(0) is changing, then we have already
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir,
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir,
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4835,12 +5178,18 @@ reswitch:
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;
       break;
 
       /* int3 */

[-- Attachment #3: floating.ChangeLog.patch --]
[-- Type: application/octet-stream, Size: 453 bytes --]

--- gdb.orig/ChangeLog	2009-08-21 21:37:18.000000000 -0400
+++ gdb.new/floating.ChangeLog	2009-08-21 21:37:13.000000000 -0400
@@ -1,3 +1,9 @@
+2009-08-21  Oza Pawandeep  <paawan1982@yahoo.com>
+
+        * i386-tdep.c:  Support for floating point recording.
+        Records and Replay the i386 floating point registers,
+        of i387 FPU.
+
 2009-08-19  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
 	* configure.ac: Call AC_DISABLE_OPTION_CHECKING.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-19  2:17 ` Hui Zhu
@ 2009-08-19  2:44   ` Hui Zhu
  0 siblings, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-08-19  2:44 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches, Mark Kettenis

[-- Attachment #1: Type: text/plain, Size: 13823 bytes --]

Oops, this is not the bug in fp patch.  Sorry for it.

After patch http://sourceware.org/ml/gdb-patches/2009-08/msg00272.html

Everything is OK.

I post a new patch that remove space in the tail.
I think you need write a changelog.  You can get a example from
src/ChangeLog.  Please Let each line doesn't bigger than 72.

Thanks,
Hui

On Wed, Aug 19, 2009 at 09:13, Hui Zhu<teawater@gmail.com> wrote:
> Could you try cvs-head?
>
> On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com> wrote:
>> Hi,
>>
>> Another analysis and observation is:
>>
>> I used gdb-6.8.50.20090803 and everything seemed okay.
>> Hui used gdb-6.8.50.20090817 and patch was still the same and gdb threw these error.
>> was there any thing major changed in gdb ?
>>
>> and gdb throws error in
>> ../../src/gdb/utils.c:1200:
>>
>> which looks like somebody has allocated memory too much or something has gone wrong in error checking.
>>
>>
>> the floating-point-patch is still the same, if it works fine with gdb-6.8.50.20090803, it is high unlikely that why should it throw memory allocation error with gdb-6.8.50.20090817 (unless system is dangerously low in virtual memory, swap space is full).
>>
>> Regards,
>> Oza.
>>
>>
>>
>> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com> wrote:
>>
>>> From: paawan oza <paawan1982@yahoo.com>
>>> Subject: Re: final i386.floating.record.patch
>>> To: "Michael Snyder" <msnyder@vmware.com>, "Hui Zhu" <teawater@gmail.com>
>>> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
>>> Date: Monday, August 17, 2009, 9:40 PM
>>> Hi Hui,
>>>
>>> I test the same and it seems working fine. Another thing I
>>> observe is, vertual memory is low problem and may be gdb's
>>> virtual address space gets exhausted or any other limit!
>>> highly unlikely though.
>>>
>>> please see the atached log.
>>>
>>> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
>>> # ./gdb ./test_floats
>>> GNU gdb (GDB) 6.8.50.20090803
>>> Copyright (C) 2009 Free Software Foundation, Inc.
>>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>>> This is free software: you are free to change and
>>> redistribute it.
>>> There is NO WARRANTY, to the extent permitted by law.
>>> Type "show copying"
>>> and "show warranty" for details.
>>> This GDB was configured as "i686-pc-linux-gnu".
>>> For bug reporting instructions, please see:
>>> <http://www.gnu.org/software/gdb/bugs/>...
>>> Setting up the environment for debugging gdb.
>>> Function "internal_error" not defined.
>>> Make breakpoint pending on future shared library load? (y
>>> or [n]) [answered N; input not from terminal]
>>> Function "info_command" not defined.
>>> Make breakpoint pending on future shared library load? (y
>>> or [n]) [answered N; input not from terminal]
>>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
>>> Error in sourced command file:
>>> No breakpoint number 0.
>>> (gdb) start
>>> Temporary breakpoint 1 at 0x8048c94: file ./test_floats.c,
>>> line 196.
>>> Starting program:
>>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
>>>
>>> Temporary breakpoint 1, main () at ./test_floats.c:196
>>> 196         init_floats();
>>> (gdb) record
>>> (gdb) c
>>> Continuing.
>>> result is 369.438751
>>> result is 10.320001
>>> result is 23.008301
>>> result is 0.000000
>>> result is 10.450000
>>> result is 10.776012
>>> result is 495830.968750
>>> result is -181.778748
>>> result is 12.525923
>>> result is 2.195619
>>> result is 5.055601
>>> result is inf
>>> result is inf
>>> result is -0.988032
>>> result is 0.154251
>>> result is -6.405331
>>> result is 1.537475
>>> The next instruction is syscall exit_group.  It will
>>> make the program exit.  Do you want to stop the
>>> program?([y] or n) y
>>> Process record: inferior program stopped.
>>>
>>> Program received signal SIGTRAP, Trace/breakpoint trap.
>>> 0xffffe405 in __kernel_vsyscall ()
>>> (gdb)
>>>
>>> Regards,
>>> Oza.
>>>
>>>
>>>
>>>
>>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
>>> wrote:
>>>
>>> > From: Hui Zhu <teawater@gmail.com>
>>> > Subject: Re: final i386.floating.record.patch
>>> > To: "Michael Snyder" <msnyder@vmware.com>
>>> > Cc: "paawan oza" <paawan1982@yahoo.com>,
>>> "gdb-patches@sourceware.org"
>>> <gdb-patches@sourceware.org>,
>>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>>> > Date: Monday, August 17, 2009, 12:06 PM
>>> > Get some error with this patch.
>>> > cat fp.c
>>> > #include <stdio.h>
>>> > #include <math.h>
>>> > #include <stdlib.h>
>>> >
>>> > /* the test intends to test following insns.
>>> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
>>> fsubrp
>>> > fucomp fnstsw fsqrt
>>> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
>>> fldl2t
>>> > fldl2e FLDPI
>>> > FLDLG2 FLDLN2
>>> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
>>> frndint
>>> > fscale fsin fcos fcmovb
>>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
>>> fstsw
>>> > */
>>> >
>>> > float no1,no2,no3,no4,no5,no6,no7;
>>> > double x = 100.345, y = 25.7789;
>>> > long double ldx = 88888888888888888888.88, ldy =
>>> > 9999999999999999999.99;
>>> > float result,resultd,resultld;
>>> > float *float_memory;
>>> >
>>> > /* initialization of floats */
>>> > void init_floats()
>>> > {
>>> >  no1 = 10.45;
>>> >  no2 = 20.77;
>>> >  no3 = 156.89874646;
>>> >  no4 = 14.56;
>>> >  no5 = 11.11;
>>> >  no6 = 66.77;
>>> >  no7 = 88.88;
>>> >  float_memory = malloc(sizeof(float) * 4);
>>> >  *float_memory = 256.256;
>>> >  *(float_memory + 1) = 356.356;
>>> >  *(float_memory + 2) = 456.456;
>>> >  *(float_memory + 3) = 556.556;
>>> > }
>>> >
>>> > /* marks FPU stack as empty */
>>> > void empty_fpu_stack()
>>> > {
>>> >  asm ("ffree %st(1) \n\t"
>>> >       "ffree %st(2) \n\t"
>>> >       "ffree %st(3) \n\t"
>>> >       "ffree %st(4) \n\t"
>>> >       "ffree %st(5) \n\t"
>>> >       "ffree %st(6) \n\t"
>>> >       "ffree %st(7)");
>>> > }
>>> >
>>> > /* tests floating point arithmatic */
>>> > void test_arith_floats()
>>> > {
>>> >  result = no1 + no2 + no3 + no4 + no5 + no6 +
>>> no7;
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = fmodf(no2,no1);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  resultd = fmod(x,y);
>>> >  printf("result is %f\n",resultd);
>>> >
>>> >  resultld = fmodl(ldy,ldy);
>>> >  printf("result is %f\n",resultld);
>>> >
>>> >  result = fabsf(no1);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = no3 / no4;
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = no1 * no2 * no3 * no4;
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = no1 - no2 - no3 - no4;
>>> >  printf("result is %f\n",result);
>>> >
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fchs");
>>> >
>>> >  /* test for f2xm1 */
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("f2xm1");
>>> >
>>> >  asm ("fyl2x");
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fxtract");
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fprem1");
>>> >
>>> >  /* decrement fpu stack pointer only status
>>> register should
>>> > get affected */
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >
>>> >  empty_fpu_stack();
>>> >
>>> >  asm ("fld1");
>>> >  asm ("fldl2t");
>>> >  asm ("fldl2e");
>>> >  asm ("fldpi");
>>> >  asm ("fldlg2");
>>> >  asm ("fldln2");
>>> >  asm ("fldz");
>>> >
>>> >  empty_fpu_stack();
>>> >  /* finishing emptying the stack */
>>> >
>>> >  result = sqrt(no3);
>>> >  printf("result is %f\n",result);
>>> > }
>>> >
>>> > void test_log_exp_floats()
>>> > {
>>> >  result = log10(no3);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = log(no3);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = exp10(no3);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = exp(no3);
>>> >  printf("result is %f\n",result);
>>> > }
>>> >
>>> > void test_trigo_floats()
>>> > {
>>> >  result = sin(30);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = cos(30);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = tan(30);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  result = atan(30);
>>> >  printf("result is %f\n",result);
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fptan");
>>> >
>>> >  /* changes st1 and popping register stack */
>>> >  asm ("fpatan");
>>> >
>>> >  asm("fincstp");
>>> >  asm ("fld %0" : :"m"(float_memory));
>>> >  asm ("fsincos");
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("frndint");
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>>> >  asm ("fscale");
>>> >
>>> >  empty_fpu_stack();
>>> >
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fsin");
>>> >  asm ("fcos");
>>> >
>>> >  /* currently we assume condition likely and
>>> always record
>>> > the registers
>>> >  code could be optimized only if the flag is set
>>> then
>>> > record */
>>> >  asm ("fld %0" : :"m"(*float_memory));
>>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>>> >  asm ("fcmovb %st(1), %st");
>>> >  asm ("fcmovbe %st(1), %st");
>>> >  asm ("fcmove %st(1), %st");
>>> >  asm ("fcmovu %st(1), %st");
>>> >  asm ("fcmovnb %st(1), %st");
>>> >  asm ("fcmovnbe %st(1), %st");
>>> >
>>> >  empty_fpu_stack();
>>> >  /* finished emtyping the stack */
>>> > }
>>> >
>>> > void test_compare_floats()
>>> > {
>>> >    ldy = 88888888888888888888.88;
>>> >    if (ldx == ldy)
>>> >      ldy =
>>> > 7777777777777777777777777777.777;
>>> >    else
>>> >      ldy =
>>> > 666666666666666666666666666.666;
>>> > }
>>> >
>>> > /* test loading and saving of FPU environment */
>>> > void test_fpu_env()
>>> > {
>>> >  asm ("fsave %0" : "=m"(*float_memory) : );
>>> >  asm ("frstor %0" : : "m"(*float_memory));
>>> >  asm ("fstsw %ax");
>>> > }
>>> >
>>> > int main()
>>> > {
>>> >    init_floats();
>>> >    test_arith_floats();
>>> >    test_log_exp_floats();
>>> >    test_trigo_floats();
>>> >    test_compare_floats();
>>> >    test_fpu_env();
>>> > }
>>> >
>>> >
>>> >
>>> > ./gdb ./a.out
>>> > GNU gdb (GDB) 6.8.50.20090817-cvs
>>> > Copyright (C) 2009 Free Software Foundation, Inc.
>>> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>>> > This is free software: you are free to change and
>>> > redistribute it.
>>> > There is NO WARRANTY, to the extent permitted by
>>> law.
>>> > Type "show copying"
>>> > and "show warranty" for details.
>>> > This GDB was configured as "i686-pc-linux-gnu".
>>> > For bug reporting instructions, please see:
>>> > <http://www.gnu.org/software/gdb/bugs/>...
>>> > Setting up the environment for debugging gdb.
>>> > Function "internal_error" not defined.
>>> > Make breakpoint pending on future shared library load?
>>> (y
>>> > or [n])
>>> > [answered N; input not from terminal]
>>> > Function "info_command" not defined.
>>> > Make breakpoint pending on future shared library load?
>>> (y
>>> > or [n])
>>> > [answered N; input not from terminal]
>>> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8: Error in
>>> sourced
>>> > command file:
>>> > No breakpoint number 0.
>>> > (gdb) start
>>> > During symbol reading, DW_AT_name missing from
>>> > DW_TAG_base_type.
>>> > Temporary breakpoint 1 at 0x8048c74: file fp.c, line
>>> 196.
>>> > Starting program: /home/teawater/gdb/bgdbno/gdb/a.out
>>> >
>>> > Temporary breakpoint 1, main () at fp.c:196
>>> > 196       init_floats();
>>> > (gdb) record
>>> > (gdb) c
>>> > Continuing.
>>> > ../../src/gdb/utils.c:1200: internal-error: virtual
>>> memory
>>> > exhausted.
>>> > A problem internal to GDB has been detected,
>>> > further debugging may prove unreliable.
>>> > Quit this debugging session? (y or n) n
>>> > ../../src/gdb/utils.c:1200: internal-error: virtual
>>> memory
>>> > exhausted.
>>> > A problem internal to GDB has been detected,
>>> > further debugging may prove unreliable.
>>> > Create a core file of GDB? (y or n) n
>>> >
>>> > Program received signal SIGTRAP, Trace/breakpoint
>>> trap.
>>> > 0xb7eba9bc in memcpy () from
>>> /lib/tls/i686/cmov/libc.so.6
>>> > (gdb) quit
>>> > A debugging session is active.
>>> >
>>> >     Inferior 1 [process 15657] will be
>>> > killed.
>>> >
>>> > Quit anyway? (y or n) y
>>> >
>>> >
>>> > Thanks,
>>> > Hui
>>> >
>>> > On Mon, Aug 17, 2009 at 05:16, Michael Snyder<msnyder@vmware.com>
>>> > wrote:
>>> > > paawan oza wrote:
>>> > >>
>>> > >> Hi Hui & Michael,
>>> > >> Now we revert status registers also.
>>> > >> please find the patch attached.
>>> > >> I am sorry, if I am not pasting the patch in
>>> > email-body due to tabs&spaces
>>> > >> problem faced by Michael last time.
>>> > >> Regards,
>>> > >> Oza.
>>> > >
>>> > > Looking good!
>>> > >
>>> > > There were some conflicts between your changes
>>> and a
>>> > check-in that
>>> > > happened after your submission  --  I've taken
>>> the
>>> > liberty of merging
>>> > > your changes with the cvs head, fixing up the
>>> > conflicts.  Hope you
>>> > > don't mind  --  merged patch attached.
>>> > >
>>> > > I'll review your tests next.
>>> > >
>>> > > Can you write up a change log entry for this
>>> patch?
>>> > >
>>> > > Hui, Mark, any more comments?
>>> > >
>>> > > Cheers,
>>> > > Michael
>>> > >
>>> > >
>>> > >
>>> > >
>>> > >
>>> >
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>

[-- Attachment #2: merged.patch --]
[-- Type: text/x-diff, Size: 14363 bytes --]

---
 i386-tdep.c |  389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 369 insertions(+), 20 deletions(-)

--- a/i386-tdep.c
+++ b/i386-tdep.c
@@ -3196,6 +3196,74 @@ i386_record_push (struct i386_record_s *
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.
+*/
+
+static int i386_record_floats (struct gdbarch *gdbarch,
+                               struct i386_record_s *ir,
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to
+     happen.  Currently we store st0-st7 registers, but we need not store all
+     registers all the time, in future we use ftag register and record only
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	      {
+	      if (record_arch_list_add_reg (ir->regcache, i))
+	        return -1;
+	      }
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  if(I386_SAVE_FPU_ENV != iregnum)
+    {
+    for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+      if (record_arch_list_add_reg (ir->regcache, i))
+        return -1;
+      }
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3214,6 +3282,7 @@ i386_process_record (struct gdbarch *gdb
   ULONGEST tmpulongest;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int rex = 0;
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
@@ -4260,8 +4329,7 @@ reswitch:
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4275,45 +4343,56 @@ reswitch:
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory. */
 	  uint64_t tmpu64;
 
 	  if (i386_record_lea_modrm_addr (&ir, &tmpu64))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+	      /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+	      /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4322,6 +4401,7 @@ reswitch:
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d:
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4330,9 +4410,14 @@ reswitch:
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c:
+            case 0x3d:
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4346,6 +4431,7 @@ reswitch:
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4356,15 +4442,49 @@ reswitch:
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (tmpu64, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (tmpu64, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (tmpu64, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4374,11 +4494,21 @@ reswitch:
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir,
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4396,6 +4526,9 @@ reswitch:
 	    case 0x2f:
 	      if (record_arch_list_add_mem (tmpu64, 2))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x1f:
 	    case 0x3e:
@@ -4417,10 +4550,17 @@ reswitch:
 		}
 	      if (record_arch_list_add_mem (tmpu64, 80))
 		return -1;
+	      /* Insn fsave.  */
+	      if (i386_record_floats (gdbarch, &ir,
+				      I386_SAVE_FPU_ENV_REG_STACK))
+		return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (tmpu64, 8))
 		return -1;
+	      /* Insn fistp.  */
+	      if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4429,8 +4569,211 @@ reswitch:
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */
+      else
+        {
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;
+	      break;
+	    case 0xd9:
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      /* If only st(0) is changing, then we have already
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir,
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir,
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir,
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir,
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4835,12 +5178,18 @@ reswitch:
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;
       break;
 
       /* int3 */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-18 15:22 paawan oza
@ 2009-08-19  2:17 ` Hui Zhu
  2009-08-19  2:44   ` Hui Zhu
  0 siblings, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-08-19  2:17 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches, Mark Kettenis

Could you try cvs-head?

On Tue, Aug 18, 2009 at 21:48, paawan oza<paawan1982@yahoo.com> wrote:
> Hi,
>
> Another analysis and observation is:
>
> I used gdb-6.8.50.20090803 and everything seemed okay.
> Hui used gdb-6.8.50.20090817 and patch was still the same and gdb threw these error.
> was there any thing major changed in gdb ?
>
> and gdb throws error in
> ../../src/gdb/utils.c:1200:
>
> which looks like somebody has allocated memory too much or something has gone wrong in error checking.
>
>
> the floating-point-patch is still the same, if it works fine with gdb-6.8.50.20090803, it is high unlikely that why should it throw memory allocation error with gdb-6.8.50.20090817 (unless system is dangerously low in virtual memory, swap space is full).
>
> Regards,
> Oza.
>
>
>
> --- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com> wrote:
>
>> From: paawan oza <paawan1982@yahoo.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "Michael Snyder" <msnyder@vmware.com>, "Hui Zhu" <teawater@gmail.com>
>> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> Date: Monday, August 17, 2009, 9:40 PM
>> Hi Hui,
>>
>> I test the same and it seems working fine. Another thing I
>> observe is, vertual memory is low problem and may be gdb's
>> virtual address space gets exhausted or any other limit!
>> highly unlikely though.
>>
>> please see the atached log.
>>
>> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
>> # ./gdb ./test_floats
>> GNU gdb (GDB) 6.8.50.20090803
>> Copyright (C) 2009 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and
>> redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.
>> Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> Setting up the environment for debugging gdb.
>> Function "internal_error" not defined.
>> Make breakpoint pending on future shared library load? (y
>> or [n]) [answered N; input not from terminal]
>> Function "info_command" not defined.
>> Make breakpoint pending on future shared library load? (y
>> or [n]) [answered N; input not from terminal]
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
>> Error in sourced command file:
>> No breakpoint number 0.
>> (gdb) start
>> Temporary breakpoint 1 at 0x8048c94: file ./test_floats.c,
>> line 196.
>> Starting program:
>> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
>>
>> Temporary breakpoint 1, main () at ./test_floats.c:196
>> 196         init_floats();
>> (gdb) record
>> (gdb) c
>> Continuing.
>> result is 369.438751
>> result is 10.320001
>> result is 23.008301
>> result is 0.000000
>> result is 10.450000
>> result is 10.776012
>> result is 495830.968750
>> result is -181.778748
>> result is 12.525923
>> result is 2.195619
>> result is 5.055601
>> result is inf
>> result is inf
>> result is -0.988032
>> result is 0.154251
>> result is -6.405331
>> result is 1.537475
>> The next instruction is syscall exit_group.  It will
>> make the program exit.  Do you want to stop the
>> program?([y] or n) y
>> Process record: inferior program stopped.
>>
>> Program received signal SIGTRAP, Trace/breakpoint trap.
>> 0xffffe405 in __kernel_vsyscall ()
>> (gdb)
>>
>> Regards,
>> Oza.
>>
>>
>>
>>
>> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
>> wrote:
>>
>> > From: Hui Zhu <teawater@gmail.com>
>> > Subject: Re: final i386.floating.record.patch
>> > To: "Michael Snyder" <msnyder@vmware.com>
>> > Cc: "paawan oza" <paawan1982@yahoo.com>,
>> "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>,
>> "Mark Kettenis" <mark.kettenis@xs4all.nl>
>> > Date: Monday, August 17, 2009, 12:06 PM
>> > Get some error with this patch.
>> > cat fp.c
>> > #include <stdio.h>
>> > #include <math.h>
>> > #include <stdlib.h>
>> >
>> > /* the test intends to test following insns.
>> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
>> fsubrp
>> > fucomp fnstsw fsqrt
>> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
>> fldl2t
>> > fldl2e FLDPI
>> > FLDLG2 FLDLN2
>> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
>> frndint
>> > fscale fsin fcos fcmovb
>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
>> fstsw
>> > */
>> >
>> > float no1,no2,no3,no4,no5,no6,no7;
>> > double x = 100.345, y = 25.7789;
>> > long double ldx = 88888888888888888888.88, ldy =
>> > 9999999999999999999.99;
>> > float result,resultd,resultld;
>> > float *float_memory;
>> >
>> > /* initialization of floats */
>> > void init_floats()
>> > {
>> >  no1 = 10.45;
>> >  no2 = 20.77;
>> >  no3 = 156.89874646;
>> >  no4 = 14.56;
>> >  no5 = 11.11;
>> >  no6 = 66.77;
>> >  no7 = 88.88;
>> >  float_memory = malloc(sizeof(float) * 4);
>> >  *float_memory = 256.256;
>> >  *(float_memory + 1) = 356.356;
>> >  *(float_memory + 2) = 456.456;
>> >  *(float_memory + 3) = 556.556;
>> > }
>> >
>> > /* marks FPU stack as empty */
>> > void empty_fpu_stack()
>> > {
>> >  asm ("ffree %st(1) \n\t"
>> >       "ffree %st(2) \n\t"
>> >       "ffree %st(3) \n\t"
>> >       "ffree %st(4) \n\t"
>> >       "ffree %st(5) \n\t"
>> >       "ffree %st(6) \n\t"
>> >       "ffree %st(7)");
>> > }
>> >
>> > /* tests floating point arithmatic */
>> > void test_arith_floats()
>> > {
>> >  result = no1 + no2 + no3 + no4 + no5 + no6 +
>> no7;
>> >  printf("result is %f\n",result);
>> >
>> >  result = fmodf(no2,no1);
>> >  printf("result is %f\n",result);
>> >
>> >  resultd = fmod(x,y);
>> >  printf("result is %f\n",resultd);
>> >
>> >  resultld = fmodl(ldy,ldy);
>> >  printf("result is %f\n",resultld);
>> >
>> >  result = fabsf(no1);
>> >  printf("result is %f\n",result);
>> >
>> >  result = no3 / no4;
>> >  printf("result is %f\n",result);
>> >
>> >  result = no1 * no2 * no3 * no4;
>> >  printf("result is %f\n",result);
>> >
>> >  result = no1 - no2 - no3 - no4;
>> >  printf("result is %f\n",result);
>> >
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fchs");
>> >
>> >  /* test for f2xm1 */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("f2xm1");
>> >
>> >  asm ("fyl2x");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fxtract");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fprem1");
>> >
>> >  /* decrement fpu stack pointer only status
>> register should
>> > get affected */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >
>> >  empty_fpu_stack();
>> >
>> >  asm ("fld1");
>> >  asm ("fldl2t");
>> >  asm ("fldl2e");
>> >  asm ("fldpi");
>> >  asm ("fldlg2");
>> >  asm ("fldln2");
>> >  asm ("fldz");
>> >
>> >  empty_fpu_stack();
>> >  /* finishing emptying the stack */
>> >
>> >  result = sqrt(no3);
>> >  printf("result is %f\n",result);
>> > }
>> >
>> > void test_log_exp_floats()
>> > {
>> >  result = log10(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = log(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = exp10(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = exp(no3);
>> >  printf("result is %f\n",result);
>> > }
>> >
>> > void test_trigo_floats()
>> > {
>> >  result = sin(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = cos(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = tan(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = atan(30);
>> >  printf("result is %f\n",result);
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fptan");
>> >
>> >  /* changes st1 and popping register stack */
>> >  asm ("fpatan");
>> >
>> >  asm("fincstp");
>> >  asm ("fld %0" : :"m"(float_memory));
>> >  asm ("fsincos");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("frndint");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >  asm ("fscale");
>> >
>> >  empty_fpu_stack();
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fsin");
>> >  asm ("fcos");
>> >
>> >  /* currently we assume condition likely and
>> always record
>> > the registers
>> >  code could be optimized only if the flag is set
>> then
>> > record */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >  asm ("fcmovb %st(1), %st");
>> >  asm ("fcmovbe %st(1), %st");
>> >  asm ("fcmove %st(1), %st");
>> >  asm ("fcmovu %st(1), %st");
>> >  asm ("fcmovnb %st(1), %st");
>> >  asm ("fcmovnbe %st(1), %st");
>> >
>> >  empty_fpu_stack();
>> >  /* finished emtyping the stack */
>> > }
>> >
>> > void test_compare_floats()
>> > {
>> >    ldy = 88888888888888888888.88;
>> >    if (ldx == ldy)
>> >      ldy =
>> > 7777777777777777777777777777.777;
>> >    else
>> >      ldy =
>> > 666666666666666666666666666.666;
>> > }
>> >
>> > /* test loading and saving of FPU environment */
>> > void test_fpu_env()
>> > {
>> >  asm ("fsave %0" : "=m"(*float_memory) : );
>> >  asm ("frstor %0" : : "m"(*float_memory));
>> >  asm ("fstsw %ax");
>> > }
>> >
>> > int main()
>> > {
>> >    init_floats();
>> >    test_arith_floats();
>> >    test_log_exp_floats();
>> >    test_trigo_floats();
>> >    test_compare_floats();
>> >    test_fpu_env();
>> > }
>> >
>> >
>> >
>> > ./gdb ./a.out
>> > GNU gdb (GDB) 6.8.50.20090817-cvs
>> > Copyright (C) 2009 Free Software Foundation, Inc.
>> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> > This is free software: you are free to change and
>> > redistribute it.
>> > There is NO WARRANTY, to the extent permitted by
>> law.
>> > Type "show copying"
>> > and "show warranty" for details.
>> > This GDB was configured as "i686-pc-linux-gnu".
>> > For bug reporting instructions, please see:
>> > <http://www.gnu.org/software/gdb/bugs/>...
>> > Setting up the environment for debugging gdb.
>> > Function "internal_error" not defined.
>> > Make breakpoint pending on future shared library load?
>> (y
>> > or [n])
>> > [answered N; input not from terminal]
>> > Function "info_command" not defined.
>> > Make breakpoint pending on future shared library load?
>> (y
>> > or [n])
>> > [answered N; input not from terminal]
>> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8: Error in
>> sourced
>> > command file:
>> > No breakpoint number 0.
>> > (gdb) start
>> > During symbol reading, DW_AT_name missing from
>> > DW_TAG_base_type.
>> > Temporary breakpoint 1 at 0x8048c74: file fp.c, line
>> 196.
>> > Starting program: /home/teawater/gdb/bgdbno/gdb/a.out
>> >
>> > Temporary breakpoint 1, main () at fp.c:196
>> > 196       init_floats();
>> > (gdb) record
>> > (gdb) c
>> > Continuing.
>> > ../../src/gdb/utils.c:1200: internal-error: virtual
>> memory
>> > exhausted.
>> > A problem internal to GDB has been detected,
>> > further debugging may prove unreliable.
>> > Quit this debugging session? (y or n) n
>> > ../../src/gdb/utils.c:1200: internal-error: virtual
>> memory
>> > exhausted.
>> > A problem internal to GDB has been detected,
>> > further debugging may prove unreliable.
>> > Create a core file of GDB? (y or n) n
>> >
>> > Program received signal SIGTRAP, Trace/breakpoint
>> trap.
>> > 0xb7eba9bc in memcpy () from
>> /lib/tls/i686/cmov/libc.so.6
>> > (gdb) quit
>> > A debugging session is active.
>> >
>> >     Inferior 1 [process 15657] will be
>> > killed.
>> >
>> > Quit anyway? (y or n) y
>> >
>> >
>> > Thanks,
>> > Hui
>> >
>> > On Mon, Aug 17, 2009 at 05:16, Michael Snyder<msnyder@vmware.com>
>> > wrote:
>> > > paawan oza wrote:
>> > >>
>> > >> Hi Hui & Michael,
>> > >> Now we revert status registers also.
>> > >> please find the patch attached.
>> > >> I am sorry, if I am not pasting the patch in
>> > email-body due to tabs&spaces
>> > >> problem faced by Michael last time.
>> > >> Regards,
>> > >> Oza.
>> > >
>> > > Looking good!
>> > >
>> > > There were some conflicts between your changes
>> and a
>> > check-in that
>> > > happened after your submission  --  I've taken
>> the
>> > liberty of merging
>> > > your changes with the cvs head, fixing up the
>> > conflicts.  Hope you
>> > > don't mind  --  merged patch attached.
>> > >
>> > > I'll review your tests next.
>> > >
>> > > Can you write up a change log entry for this
>> patch?
>> > >
>> > > Hui, Mark, any more comments?
>> > >
>> > > Cheers,
>> > > Michael
>> > >
>> > >
>> > >
>> > >
>> > >
>> >
>>
>>
>>
>>
>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
@ 2009-08-18 15:22 paawan oza
  2009-08-19  2:17 ` Hui Zhu
  0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-08-18 15:22 UTC (permalink / raw)
  To: Michael Snyder, Hui Zhu; +Cc: gdb-patches, Mark Kettenis

Hi,

Another analysis and observation is:

I used gdb-6.8.50.20090803 and everything seemed okay.
Hui used gdb-6.8.50.20090817 and patch was still the same and gdb threw these error.
was there any thing major changed in gdb ?

and gdb throws error in 
../../src/gdb/utils.c:1200: 

which looks like somebody has allocated memory too much or something has gone wrong in error checking.


the floating-point-patch is still the same, if it works fine with gdb-6.8.50.20090803, it is high unlikely that why should it throw memory allocation error with gdb-6.8.50.20090817 (unless system is dangerously low in virtual memory, swap space is full).

Regards,
Oza.



--- On Mon, 8/17/09, paawan oza <paawan1982@yahoo.com> wrote:

> From: paawan oza <paawan1982@yahoo.com>
> Subject: Re: final i386.floating.record.patch
> To: "Michael Snyder" <msnyder@vmware.com>, "Hui Zhu" <teawater@gmail.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
> Date: Monday, August 17, 2009, 9:40 PM
> Hi Hui,
> 
> I test the same and it seems working fine. Another thing I
> observe is, vertual memory is low problem and may be gdb's
> virtual address space gets exhausted or any other limit!
> highly unlikely though.
> 
> please see the atached log.
> 
> linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb
> # ./gdb ./test_floats
> GNU gdb (GDB) 6.8.50.20090803
> Copyright (C) 2009 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and
> redistribute it.
> There is NO WARRANTY, to the extent permitted by law. 
> Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Setting up the environment for debugging gdb.
> Function "internal_error" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n]) [answered N; input not from terminal]
> Function "info_command" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n]) [answered N; input not from terminal]
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8:
> Error in sourced command file:
> No breakpoint number 0.
> (gdb) start
> Temporary breakpoint 1 at 0x8048c94: file ./test_floats.c,
> line 196.
> Starting program:
> /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats
> 
> Temporary breakpoint 1, main () at ./test_floats.c:196
> 196         init_floats();
> (gdb) record
> (gdb) c
> Continuing.
> result is 369.438751
> result is 10.320001
> result is 23.008301
> result is 0.000000
> result is 10.450000
> result is 10.776012
> result is 495830.968750
> result is -181.778748
> result is 12.525923
> result is 2.195619
> result is 5.055601
> result is inf
> result is inf
> result is -0.988032
> result is 0.154251
> result is -6.405331
> result is 1.537475
> The next instruction is syscall exit_group.  It will
> make the program exit.  Do you want to stop the
> program?([y] or n) y
> Process record: inferior program stopped.
> 
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0xffffe405 in __kernel_vsyscall ()
> (gdb)
> 
> Regards,
> Oza.
> 
> 
> 
> 
> --- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com>
> wrote:
> 
> > From: Hui Zhu <teawater@gmail.com>
> > Subject: Re: final i386.floating.record.patch
> > To: "Michael Snyder" <msnyder@vmware.com>
> > Cc: "paawan oza" <paawan1982@yahoo.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>
> > Date: Monday, August 17, 2009, 12:06 PM
> > Get some error with this patch.
> > cat fp.c
> > #include <stdio.h>
> > #include <math.h>
> > #include <stdlib.h>
> > 
> > /* the test intends to test following insns.
> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
> fsubrp
> > fucomp fnstsw fsqrt
> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
> fldl2t
> > fldl2e FLDPI
> > FLDLG2 FLDLN2
> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
> frndint
> > fscale fsin fcos fcmovb
> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
> fstsw
> > */
> > 
> > float no1,no2,no3,no4,no5,no6,no7;
> > double x = 100.345, y = 25.7789;
> > long double ldx = 88888888888888888888.88, ldy =
> > 9999999999999999999.99;
> > float result,resultd,resultld;
> > float *float_memory;
> > 
> > /* initialization of floats */
> > void init_floats()
> > {
> >  no1 = 10.45;
> >  no2 = 20.77;
> >  no3 = 156.89874646;
> >  no4 = 14.56;
> >  no5 = 11.11;
> >  no6 = 66.77;
> >  no7 = 88.88;
> >  float_memory = malloc(sizeof(float) * 4);
> >  *float_memory = 256.256;
> >  *(float_memory + 1) = 356.356;
> >  *(float_memory + 2) = 456.456;
> >  *(float_memory + 3) = 556.556;
> > }
> > 
> > /* marks FPU stack as empty */
> > void empty_fpu_stack()
> > {
> >  asm ("ffree %st(1) \n\t"
> >       "ffree %st(2) \n\t"
> >       "ffree %st(3) \n\t"
> >       "ffree %st(4) \n\t"
> >       "ffree %st(5) \n\t"
> >       "ffree %st(6) \n\t"
> >       "ffree %st(7)");
> > }
> > 
> > /* tests floating point arithmatic */
> > void test_arith_floats()
> > {
> >  result = no1 + no2 + no3 + no4 + no5 + no6 +
> no7;
> >  printf("result is %f\n",result);
> > 
> >  result = fmodf(no2,no1);
> >  printf("result is %f\n",result);
> > 
> >  resultd = fmod(x,y);
> >  printf("result is %f\n",resultd);
> > 
> >  resultld = fmodl(ldy,ldy);
> >  printf("result is %f\n",resultld);
> > 
> >  result = fabsf(no1);
> >  printf("result is %f\n",result);
> > 
> >  result = no3 / no4;
> >  printf("result is %f\n",result);
> > 
> >  result = no1 * no2 * no3 * no4;
> >  printf("result is %f\n",result);
> > 
> >  result = no1 - no2 - no3 - no4;
> >  printf("result is %f\n",result);
> > 
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fchs");
> > 
> >  /* test for f2xm1 */
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("f2xm1");
> > 
> >  asm ("fyl2x");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fxtract");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fprem1");
> > 
> >  /* decrement fpu stack pointer only status
> register should
> > get affected */
> >  asm ("fld %0" : :"m"(*float_memory));
> > 
> >  empty_fpu_stack();
> > 
> >  asm ("fld1");
> >  asm ("fldl2t");
> >  asm ("fldl2e");
> >  asm ("fldpi");
> >  asm ("fldlg2");
> >  asm ("fldln2");
> >  asm ("fldz");
> > 
> >  empty_fpu_stack();
> >  /* finishing emptying the stack */
> > 
> >  result = sqrt(no3);
> >  printf("result is %f\n",result);
> > }
> > 
> > void test_log_exp_floats()
> > {
> >  result = log10(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = log(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = exp10(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = exp(no3);
> >  printf("result is %f\n",result);
> > }
> > 
> > void test_trigo_floats()
> > {
> >  result = sin(30);
> >  printf("result is %f\n",result);
> > 
> >  result = cos(30);
> >  printf("result is %f\n",result);
> > 
> >  result = tan(30);
> >  printf("result is %f\n",result);
> > 
> >  result = atan(30);
> >  printf("result is %f\n",result);
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fptan");
> > 
> >  /* changes st1 and popping register stack */
> >  asm ("fpatan");
> > 
> >  asm("fincstp");
> >  asm ("fld %0" : :"m"(float_memory));
> >  asm ("fsincos");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("frndint");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >  asm ("fscale");
> > 
> >  empty_fpu_stack();
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fsin");
> >  asm ("fcos");
> > 
> >  /* currently we assume condition likely and
> always record
> > the registers
> >  code could be optimized only if the flag is set
> then
> > record */
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >  asm ("fcmovb %st(1), %st");
> >  asm ("fcmovbe %st(1), %st");
> >  asm ("fcmove %st(1), %st");
> >  asm ("fcmovu %st(1), %st");
> >  asm ("fcmovnb %st(1), %st");
> >  asm ("fcmovnbe %st(1), %st");
> > 
> >  empty_fpu_stack();
> >  /* finished emtyping the stack */
> > }
> > 
> > void test_compare_floats()
> > {
> >    ldy = 88888888888888888888.88;
> >    if (ldx == ldy)
> >      ldy =
> > 7777777777777777777777777777.777;
> >    else
> >      ldy =
> > 666666666666666666666666666.666;
> > }
> > 
> > /* test loading and saving of FPU environment */
> > void test_fpu_env()
> > {
> >  asm ("fsave %0" : "=m"(*float_memory) : );
> >  asm ("frstor %0" : : "m"(*float_memory));
> >  asm ("fstsw %ax");
> > }
> > 
> > int main()
> > {
> >    init_floats();
> >    test_arith_floats();
> >    test_log_exp_floats();
> >    test_trigo_floats();
> >    test_compare_floats();
> >    test_fpu_env();
> > }
> > 
> > 
> > 
> > ./gdb ./a.out
> > GNU gdb (GDB) 6.8.50.20090817-cvs
> > Copyright (C) 2009 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and
> > redistribute it.
> > There is NO WARRANTY, to the extent permitted by
> law. 
> > Type "show copying"
> > and "show warranty" for details.
> > This GDB was configured as "i686-pc-linux-gnu".
> > For bug reporting instructions, please see:
> > <http://www.gnu.org/software/gdb/bugs/>...
> > Setting up the environment for debugging gdb.
> > Function "internal_error" not defined.
> > Make breakpoint pending on future shared library load?
> (y
> > or [n])
> > [answered N; input not from terminal]
> > Function "info_command" not defined.
> > Make breakpoint pending on future shared library load?
> (y
> > or [n])
> > [answered N; input not from terminal]
> > /home/teawater/gdb/bgdbno/gdb/.gdbinit:8: Error in
> sourced
> > command file:
> > No breakpoint number 0.
> > (gdb) start
> > During symbol reading, DW_AT_name missing from
> > DW_TAG_base_type.
> > Temporary breakpoint 1 at 0x8048c74: file fp.c, line
> 196.
> > Starting program: /home/teawater/gdb/bgdbno/gdb/a.out
> > 
> > Temporary breakpoint 1, main () at fp.c:196
> > 196       init_floats();
> > (gdb) record
> > (gdb) c
> > Continuing.
> > ../../src/gdb/utils.c:1200: internal-error: virtual
> memory
> > exhausted.
> > A problem internal to GDB has been detected,
> > further debugging may prove unreliable.
> > Quit this debugging session? (y or n) n
> > ../../src/gdb/utils.c:1200: internal-error: virtual
> memory
> > exhausted.
> > A problem internal to GDB has been detected,
> > further debugging may prove unreliable.
> > Create a core file of GDB? (y or n) n
> > 
> > Program received signal SIGTRAP, Trace/breakpoint
> trap.
> > 0xb7eba9bc in memcpy () from
> /lib/tls/i686/cmov/libc.so.6
> > (gdb) quit
> > A debugging session is active.
> > 
> >     Inferior 1 [process 15657] will be
> > killed.
> > 
> > Quit anyway? (y or n) y
> > 
> > 
> > Thanks,
> > Hui
> > 
> > On Mon, Aug 17, 2009 at 05:16, Michael Snyder<msnyder@vmware.com>
> > wrote:
> > > paawan oza wrote:
> > >>
> > >> Hi Hui & Michael,
> > >> Now we revert status registers also.
> > >> please find the patch attached.
> > >> I am sorry, if I am not pasting the patch in
> > email-body due to tabs&spaces
> > >> problem faced by Michael last time.
> > >> Regards,
> > >> Oza.
> > >
> > > Looking good!
> > >
> > > There were some conflicts between your changes
> and a
> > check-in that
> > > happened after your submission  --  I've taken
> the
> > liberty of merging
> > > your changes with the cvs head, fixing up the
> > conflicts.  Hope you
> > > don't mind  --  merged patch attached.
> > >
> > > I'll review your tests next.
> > >
> > > Can you write up a change log entry for this
> patch?
> > >
> > > Hui, Mark, any more comments?
> > >
> > > Cheers,
> > > Michael
> > >
> > >
> > >
> > >
> > >
> > 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-17  9:17   ` Hui Zhu
@ 2009-08-17 16:16     ` paawan oza
  0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-17 16:16 UTC (permalink / raw)
  To: Michael Snyder, Hui Zhu; +Cc: gdb-patches, Mark Kettenis

Hi Hui,

I test the same and it seems working fine. Another thing I observe is, vertual memory is low problem and may be gdb's virtual address space gets exhausted or any other limit! highly unlikely though.

please see the atached log.

linux-p94d:/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb # ./gdb ./test_floats
GNU gdb (GDB) 6.8.50.20090803
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
/home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) start
Temporary breakpoint 1 at 0x8048c94: file ./test_floats.c, line 196.
Starting program: /home/oza/mk_patch/take_diff/gdb_current/gdb-6.8.50.20090803/gdb/test_floats

Temporary breakpoint 1, main () at ./test_floats.c:196
196         init_floats();
(gdb) record
(gdb) c
Continuing.
result is 369.438751
result is 10.320001
result is 23.008301
result is 0.000000
result is 10.450000
result is 10.776012
result is 495830.968750
result is -181.778748
result is 12.525923
result is 2.195619
result is 5.055601
result is inf
result is inf
result is -0.988032
result is 0.154251
result is -6.405331
result is 1.537475
The next instruction is syscall exit_group.  It will make the program exit.  Do you want to stop the program?([y] or n) y
Process record: inferior program stopped.

Program received signal SIGTRAP, Trace/breakpoint trap.
0xffffe405 in __kernel_vsyscall ()
(gdb)

Regards,
Oza.




--- On Mon, 8/17/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "Michael Snyder" <msnyder@vmware.com>
> Cc: "paawan oza" <paawan1982@yahoo.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Mark Kettenis" <mark.kettenis@xs4all.nl>
> Date: Monday, August 17, 2009, 12:06 PM
> Get some error with this patch.
> cat fp.c
> #include <stdio.h>
> #include <math.h>
> #include <stdlib.h>
> 
> /* the test intends to test following insns.
> flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp
> fucomp fnstsw fsqrt
> fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t
> fldl2e FLDPI
> FLDLG2 FLDLN2
> FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint
> fscale fsin fcos fcmovb
> fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
> */
> 
> float no1,no2,no3,no4,no5,no6,no7;
> double x = 100.345, y = 25.7789;
> long double ldx = 88888888888888888888.88, ldy =
> 9999999999999999999.99;
> float result,resultd,resultld;
> float *float_memory;
> 
> /* initialization of floats */
> void init_floats()
> {
>  no1 = 10.45;
>  no2 = 20.77;
>  no3 = 156.89874646;
>  no4 = 14.56;
>  no5 = 11.11;
>  no6 = 66.77;
>  no7 = 88.88;
>  float_memory = malloc(sizeof(float) * 4);
>  *float_memory = 256.256;
>  *(float_memory + 1) = 356.356;
>  *(float_memory + 2) = 456.456;
>  *(float_memory + 3) = 556.556;
> }
> 
> /* marks FPU stack as empty */
> void empty_fpu_stack()
> {
>  asm ("ffree %st(1) \n\t"
>       "ffree %st(2) \n\t"
>       "ffree %st(3) \n\t"
>       "ffree %st(4) \n\t"
>       "ffree %st(5) \n\t"
>       "ffree %st(6) \n\t"
>       "ffree %st(7)");
> }
> 
> /* tests floating point arithmatic */
> void test_arith_floats()
> {
>  result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
>  printf("result is %f\n",result);
> 
>  result = fmodf(no2,no1);
>  printf("result is %f\n",result);
> 
>  resultd = fmod(x,y);
>  printf("result is %f\n",resultd);
> 
>  resultld = fmodl(ldy,ldy);
>  printf("result is %f\n",resultld);
> 
>  result = fabsf(no1);
>  printf("result is %f\n",result);
> 
>  result = no3 / no4;
>  printf("result is %f\n",result);
> 
>  result = no1 * no2 * no3 * no4;
>  printf("result is %f\n",result);
> 
>  result = no1 - no2 - no3 - no4;
>  printf("result is %f\n",result);
> 
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fchs");
> 
>  /* test for f2xm1 */
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("f2xm1");
> 
>  asm ("fyl2x");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fxtract");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fprem1");
> 
>  /* decrement fpu stack pointer only status register should
> get affected */
>  asm ("fld %0" : :"m"(*float_memory));
> 
>  empty_fpu_stack();
> 
>  asm ("fld1");
>  asm ("fldl2t");
>  asm ("fldl2e");
>  asm ("fldpi");
>  asm ("fldlg2");
>  asm ("fldln2");
>  asm ("fldz");
> 
>  empty_fpu_stack();
>  /* finishing emptying the stack */
> 
>  result = sqrt(no3);
>  printf("result is %f\n",result);
> }
> 
> void test_log_exp_floats()
> {
>  result = log10(no3);
>  printf("result is %f\n",result);
> 
>  result = log(no3);
>  printf("result is %f\n",result);
> 
>  result = exp10(no3);
>  printf("result is %f\n",result);
> 
>  result = exp(no3);
>  printf("result is %f\n",result);
> }
> 
> void test_trigo_floats()
> {
>  result = sin(30);
>  printf("result is %f\n",result);
> 
>  result = cos(30);
>  printf("result is %f\n",result);
> 
>  result = tan(30);
>  printf("result is %f\n",result);
> 
>  result = atan(30);
>  printf("result is %f\n",result);
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fptan");
> 
>  /* changes st1 and popping register stack */
>  asm ("fpatan");
> 
>  asm("fincstp");
>  asm ("fld %0" : :"m"(float_memory));
>  asm ("fsincos");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("frndint");
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fld %0" : :"m"(*(float_memory+1)));
>  asm ("fscale");
> 
>  empty_fpu_stack();
> 
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fsin");
>  asm ("fcos");
> 
>  /* currently we assume condition likely and always record
> the registers
>  code could be optimized only if the flag is set then
> record */
>  asm ("fld %0" : :"m"(*float_memory));
>  asm ("fld %0" : :"m"(*(float_memory+1)));
>  asm ("fcmovb %st(1), %st");
>  asm ("fcmovbe %st(1), %st");
>  asm ("fcmove %st(1), %st");
>  asm ("fcmovu %st(1), %st");
>  asm ("fcmovnb %st(1), %st");
>  asm ("fcmovnbe %st(1), %st");
> 
>  empty_fpu_stack();
>  /* finished emtyping the stack */
> }
> 
> void test_compare_floats()
> {
>    ldy = 88888888888888888888.88;
>    if (ldx == ldy)
>      ldy =
> 7777777777777777777777777777.777;
>    else
>      ldy =
> 666666666666666666666666666.666;
> }
> 
> /* test loading and saving of FPU environment */
> void test_fpu_env()
> {
>  asm ("fsave %0" : "=m"(*float_memory) : );
>  asm ("frstor %0" : : "m"(*float_memory));
>  asm ("fstsw %ax");
> }
> 
> int main()
> {
>    init_floats();
>    test_arith_floats();
>    test_log_exp_floats();
>    test_trigo_floats();
>    test_compare_floats();
>    test_fpu_env();
> }
> 
> 
> 
> ./gdb ./a.out
> GNU gdb (GDB) 6.8.50.20090817-cvs
> Copyright (C) 2009 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and
> redistribute it.
> There is NO WARRANTY, to the extent permitted by law. 
> Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Setting up the environment for debugging gdb.
> Function "internal_error" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n])
> [answered N; input not from terminal]
> Function "info_command" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n])
> [answered N; input not from terminal]
> /home/teawater/gdb/bgdbno/gdb/.gdbinit:8: Error in sourced
> command file:
> No breakpoint number 0.
> (gdb) start
> During symbol reading, DW_AT_name missing from
> DW_TAG_base_type.
> Temporary breakpoint 1 at 0x8048c74: file fp.c, line 196.
> Starting program: /home/teawater/gdb/bgdbno/gdb/a.out
> 
> Temporary breakpoint 1, main () at fp.c:196
> 196       init_floats();
> (gdb) record
> (gdb) c
> Continuing.
> ../../src/gdb/utils.c:1200: internal-error: virtual memory
> exhausted.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n) n
> ../../src/gdb/utils.c:1200: internal-error: virtual memory
> exhausted.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Create a core file of GDB? (y or n) n
> 
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0xb7eba9bc in memcpy () from /lib/tls/i686/cmov/libc.so.6
> (gdb) quit
> A debugging session is active.
> 
>     Inferior 1 [process 15657] will be
> killed.
> 
> Quit anyway? (y or n) y
> 
> 
> Thanks,
> Hui
> 
> On Mon, Aug 17, 2009 at 05:16, Michael Snyder<msnyder@vmware.com>
> wrote:
> > paawan oza wrote:
> >>
> >> Hi Hui & Michael,
> >> Now we revert status registers also.
> >> please find the patch attached.
> >> I am sorry, if I am not pasting the patch in
> email-body due to tabs&spaces
> >> problem faced by Michael last time.
> >> Regards,
> >> Oza.
> >
> > Looking good!
> >
> > There were some conflicts between your changes and a
> check-in that
> > happened after your submission  --  I've taken the
> liberty of merging
> > your changes with the cvs head, fixing up the
> conflicts.  Hope you
> > don't mind  --  merged patch attached.
> >
> > I'll review your tests next.
> >
> > Can you write up a change log entry for this patch?
> >
> > Hui, Mark, any more comments?
> >
> > Cheers,
> > Michael
> >
> >
> >
> >
> >
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-16 21:41 ` Michael Snyder
@ 2009-08-17  9:17   ` Hui Zhu
  2009-08-17 16:16     ` paawan oza
  0 siblings, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-08-17  9:17 UTC (permalink / raw)
  To: Michael Snyder; +Cc: paawan oza, gdb-patches, Mark Kettenis

Get some error with this patch.
cat fp.c
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI
FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/

float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;

/* initialization of floats */
void init_floats()
{
 no1 = 10.45;
 no2 = 20.77;
 no3 = 156.89874646;
 no4 = 14.56;
 no5 = 11.11;
 no6 = 66.77;
 no7 = 88.88;
 float_memory = malloc(sizeof(float) * 4);
 *float_memory = 256.256;
 *(float_memory + 1) = 356.356;
 *(float_memory + 2) = 456.456;
 *(float_memory + 3) = 556.556;
}

/* marks FPU stack as empty */
void empty_fpu_stack()
{
 asm ("ffree %st(1) \n\t"
      "ffree %st(2) \n\t"
      "ffree %st(3) \n\t"
      "ffree %st(4) \n\t"
      "ffree %st(5) \n\t"
      "ffree %st(6) \n\t"
      "ffree %st(7)");
}

/* tests floating point arithmatic */
void test_arith_floats()
{
 result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
 printf("result is %f\n",result);

 result = fmodf(no2,no1);
 printf("result is %f\n",result);

 resultd = fmod(x,y);
 printf("result is %f\n",resultd);

 resultld = fmodl(ldy,ldy);
 printf("result is %f\n",resultld);

 result = fabsf(no1);
 printf("result is %f\n",result);

 result = no3 / no4;
 printf("result is %f\n",result);

 result = no1 * no2 * no3 * no4;
 printf("result is %f\n",result);

 result = no1 - no2 - no3 - no4;
 printf("result is %f\n",result);


 asm ("fld %0" : :"m"(*float_memory));
 asm ("fchs");

 /* test for f2xm1 */
 asm ("fld %0" : :"m"(*float_memory));
 asm ("f2xm1");

 asm ("fyl2x");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fxtract");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fprem1");

 /* decrement fpu stack pointer only status register should get affected */
 asm ("fld %0" : :"m"(*float_memory));

 empty_fpu_stack();

 asm ("fld1");
 asm ("fldl2t");
 asm ("fldl2e");
 asm ("fldpi");
 asm ("fldlg2");
 asm ("fldln2");
 asm ("fldz");

 empty_fpu_stack();
 /* finishing emptying the stack */

 result = sqrt(no3);
 printf("result is %f\n",result);
}

void test_log_exp_floats()
{
 result = log10(no3);
 printf("result is %f\n",result);

 result = log(no3);
 printf("result is %f\n",result);

 result = exp10(no3);
 printf("result is %f\n",result);

 result = exp(no3);
 printf("result is %f\n",result);
}

void test_trigo_floats()
{
 result = sin(30);
 printf("result is %f\n",result);

 result = cos(30);
 printf("result is %f\n",result);

 result = tan(30);
 printf("result is %f\n",result);

 result = atan(30);
 printf("result is %f\n",result);

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fptan");

 /* changes st1 and popping register stack */
 asm ("fpatan");

 asm("fincstp");
 asm ("fld %0" : :"m"(float_memory));
 asm ("fsincos");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("frndint");

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fld %0" : :"m"(*(float_memory+1)));
 asm ("fscale");

 empty_fpu_stack();

 asm ("fld %0" : :"m"(*float_memory));
 asm ("fsin");
 asm ("fcos");

 /* currently we assume condition likely and always record the registers
 code could be optimized only if the flag is set then record */
 asm ("fld %0" : :"m"(*float_memory));
 asm ("fld %0" : :"m"(*(float_memory+1)));
 asm ("fcmovb %st(1), %st");
 asm ("fcmovbe %st(1), %st");
 asm ("fcmove %st(1), %st");
 asm ("fcmovu %st(1), %st");
 asm ("fcmovnb %st(1), %st");
 asm ("fcmovnbe %st(1), %st");

 empty_fpu_stack();
 /* finished emtyping the stack */
}

void test_compare_floats()
{
   ldy = 88888888888888888888.88;
   if (ldx == ldy)
     ldy = 7777777777777777777777777777.777;
   else
     ldy = 666666666666666666666666666.666;
}

/* test loading and saving of FPU environment */
void test_fpu_env()
{
 asm ("fsave %0" : "=m"(*float_memory) : );
 asm ("frstor %0" : : "m"(*float_memory));
 asm ("fstsw %ax");
}

int main()
{
   init_floats();
   test_arith_floats();
   test_log_exp_floats();
   test_trigo_floats();
   test_compare_floats();
   test_fpu_env();
}



./gdb ./a.out
GNU gdb (GDB) 6.8.50.20090817-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
/home/teawater/gdb/bgdbno/gdb/.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) start
During symbol reading, DW_AT_name missing from DW_TAG_base_type.
Temporary breakpoint 1 at 0x8048c74: file fp.c, line 196.
Starting program: /home/teawater/gdb/bgdbno/gdb/a.out

Temporary breakpoint 1, main () at fp.c:196
196	   init_floats();
(gdb) record
(gdb) c
Continuing.
../../src/gdb/utils.c:1200: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
../../src/gdb/utils.c:1200: internal-error: virtual memory exhausted.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n

Program received signal SIGTRAP, Trace/breakpoint trap.
0xb7eba9bc in memcpy () from /lib/tls/i686/cmov/libc.so.6
(gdb) quit
A debugging session is active.

	Inferior 1 [process 15657] will be killed.

Quit anyway? (y or n) y


Thanks,
Hui

On Mon, Aug 17, 2009 at 05:16, Michael Snyder<msnyder@vmware.com> wrote:
> paawan oza wrote:
>>
>> Hi Hui & Michael,
>> Now we revert status registers also.
>> please find the patch attached.
>> I am sorry, if I am not pasting the patch in email-body due to tabs&spaces
>> problem faced by Michael last time.
>> Regards,
>> Oza.
>
> Looking good!
>
> There were some conflicts between your changes and a check-in that
> happened after your submission  --  I've taken the liberty of merging
> your changes with the cvs head, fixing up the conflicts.  Hope you
> don't mind  --  merged patch attached.
>
> I'll review your tests next.
>
> Can you write up a change log entry for this patch?
>
> Hui, Mark, any more comments?
>
> Cheers,
> Michael
>
>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-07  7:25 paawan oza
  2009-08-07 15:50 ` Hui Zhu
@ 2009-08-16 21:41 ` Michael Snyder
  2009-08-17  9:17   ` Hui Zhu
  1 sibling, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-08-16 21:41 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, gdb-patches, Mark Kettenis

[-- Attachment #1: Type: text/plain, Size: 636 bytes --]

paawan oza wrote:
> Hi Hui & Michael,
> Now we revert status registers also.
> please find the patch attached.
> I am sorry, if I am not pasting the patch in email-body due to tabs&spaces problem faced by Michael last time.
> Regards,
> Oza.

Looking good!

There were some conflicts between your changes and a check-in that
happened after your submission  --  I've taken the liberty of merging
your changes with the cvs head, fixing up the conflicts.  Hope you
don't mind  --  merged patch attached.

I'll review your tests next.

Can you write up a change log entry for this patch?

Hui, Mark, any more comments?

Cheers,
Michael





[-- Attachment #2: merged.patch --]
[-- Type: text/x-patch, Size: 14500 bytes --]

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.283
diff -u -p -r1.283 i386-tdep.c
--- i386-tdep.c	10 Aug 2009 03:02:39 -0000	1.283
+++ i386-tdep.c	16 Aug 2009 21:14:04 -0000
@@ -3196,6 +3196,74 @@ i386_record_push (struct i386_record_s *
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.  
+*/
+
+static int i386_record_floats (struct gdbarch *gdbarch, 
+                               struct i386_record_s *ir, 
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to 
+     happen.  Currently we store st0-st7 registers, but we need not store all 
+     registers all the time, in future we use ftag register and record only 
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	      {
+	      if (record_arch_list_add_reg (ir->regcache, i))
+	        return -1;
+	      }
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) && 
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  if(I386_SAVE_FPU_ENV != iregnum)
+    {
+    for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+      if (record_arch_list_add_reg (ir->regcache, i))
+        return -1;
+      }
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3214,6 +3282,7 @@ i386_process_record (struct gdbarch *gdb
   ULONGEST tmpulongest;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int rex = 0;
   uint8_t rex_w = -1;
   uint8_t rex_r = 0;
@@ -4260,8 +4329,7 @@ reswitch:
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4275,45 +4343,56 @@ reswitch:
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory. */
 	  uint64_t tmpu64;
 
 	  if (i386_record_lea_modrm_addr (&ir, &tmpu64))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+	      /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+	      /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4322,6 +4401,7 @@ reswitch:
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d: 
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4330,9 +4410,14 @@ reswitch:
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c: 
+            case 0x3d: 
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4346,6 +4431,7 @@ reswitch:
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4356,15 +4442,49 @@ reswitch:
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (tmpu64, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (tmpu64, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (tmpu64, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir,
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */
 		    default:
 		      if (record_arch_list_add_mem (tmpu64, 2))
 			return -1;
@@ -4374,11 +4494,21 @@ reswitch:
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4396,6 +4526,9 @@ reswitch:
 	    case 0x2f:
 	      if (record_arch_list_add_mem (tmpu64, 2))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x1f:
 	    case 0x3e:
@@ -4417,10 +4550,17 @@ reswitch:
 		}
 	      if (record_arch_list_add_mem (tmpu64, 80))
 		return -1;
+	      /* Insn fsave.  */
+	      if (i386_record_floats (gdbarch, &ir,
+				      I386_SAVE_FPU_ENV_REG_STACK))
+		return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (tmpu64, 8))
 		return -1;
+	      /* Insn fistp.  */
+	      if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4429,8 +4569,211 @@ reswitch:
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */
+      else
+        { 
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;
+	      break;
+	    case 0xd9:
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      /* If only st(0) is changing, then we have already 
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir, 
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;	 
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4835,12 +5178,18 @@ reswitch:
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;
       break;
 
       /* int3 */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-07  7:25 paawan oza
@ 2009-08-07 15:50 ` Hui Zhu
  2009-08-16 21:41 ` Michael Snyder
  1 sibling, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-08-07 15:50 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches

Thanks for your work.

I try with fp program, looks ok now.

And for format of the patch:
There is a lot of spaces tail in the tail of the codes.
For example:
"+			    return -1;	                      "
"/* Opcode is an extension of modR/M byte.  */     "

Hui

On Fri, Aug 7, 2009 at 15:17, paawan oza<paawan1982@yahoo.com> wrote:
> Hi Hui & Michael,
> Now we revert status registers also.
> please find the patch attached.
> I am sorry, if I am not pasting the patch in email-body due to tabs&spaces problem faced by Michael last time.
> Regards,
> Oza.
>
> --- On Wed, 8/5/09, Michael Snyder <msnyder@vmware.com> wrote:
>
>> From: Michael Snyder <msnyder@vmware.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Hui Zhu" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Wednesday, August 5, 2009, 7:03 AM
>> paawan oza wrote:
>> > Hi Hui,
>> >
>> > please find my analysis as follows.
>> >
>> > following are the registers which you may find it
>> different.
>> >
>> > fstat
>> > ftag
>> > fiseg
>> > fioff
>> > foseg
>> > fooff
>> > fop
>> >
>> > In my opinion, we do not need to record all these
>> registers. because these registers are purly depends on
>> instruction's execution status in FPU unit.
>> >
>> >
>> > for e.g.
>> > fop register stores te last opcode executed by x87 FPU
>> unit.
>> > fstat register may contain c0, c1, c2, c3 flag
>> status...
>> >
>> > why we dont need to record, because even if we reply
>> the recod...
>> > Anyway these register are going to be change by FPU HW
>> unit based on any fp insn's nature and its execution. (next
>> insn which FPU is going to execute)
>> >
>> > so it doesnt make much sense to store it, because even
>> if we restore it, FPU unit doesnt use them directly, but FPU
>> HW sets them after executing current fp insn. so anyway they
>> are going to reset as soon as FPU executes next insn.
>> >
>> > but still if you feel that we must record those
>> registers because user might want to observe those
>> registers, then I can do that.
>> >
>> > please let me know you opinion about it.
>>
>> It may be that saving the registers is not purely
>> necessary, but
>> we are not just a simulator -- we are a debugger.  The
>> user might
>> be confused if he steps backward and sees that the register
>> did not
>> change.
>>
>> So I think we should preserve it and revert it.
>>
>>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
@ 2009-08-07  7:25 paawan oza
  2009-08-07 15:50 ` Hui Zhu
  2009-08-16 21:41 ` Michael Snyder
  0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-08-07  7:25 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]

Hi Hui & Michael,
Now we revert status registers also.
please find the patch attached.
I am sorry, if I am not pasting the patch in email-body due to tabs&spaces problem faced by Michael last time.
Regards,
Oza.

--- On Wed, 8/5/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Wednesday, August 5, 2009, 7:03 AM
> paawan oza wrote:
> > Hi Hui,
> > 
> > please find my analysis as follows.
> > 
> > following are the registers which you may find it
> different.
> > 
> > fstat
> > ftag
> > fiseg
> > fioff
> > foseg
> > fooff
> > fop
> > 
> > In my opinion, we do not need to record all these
> registers. because these registers are purly depends on
> instruction's execution status in FPU unit.
> > 
> > 
> > for e.g.
> > fop register stores te last opcode executed by x87 FPU
> unit.
> > fstat register may contain c0, c1, c2, c3 flag
> status...
> > 
> > why we dont need to record, because even if we reply
> the recod...
> > Anyway these register are going to be change by FPU HW
> unit based on any fp insn's nature and its execution. (next
> insn which FPU is going to execute)
> > 
> > so it doesnt make much sense to store it, because even
> if we restore it, FPU unit doesnt use them directly, but FPU
> HW sets them after executing current fp insn. so anyway they
> are going to reset as soon as FPU executes next insn.
> > 
> > but still if you feel that we must record those
> registers because user might want to observe those
> registers, then I can do that.
> > 
> > please let me know you opinion about it.
> 
> It may be that saving the registers is not purely
> necessary, but
> we are not just a simulator -- we are a debugger.  The
> user might
> be confused if he steps backward and sees that the register
> did not
> change.
> 
> So I think we should preserve it and revert it.
> 
>


      

[-- Attachment #2: i386.record.float.aug-07.patch --]
[-- Type: application/octet-stream, Size: 14374 bytes --]

diff -urN ./gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- ./gdb.orig/i386-tdep.c	2009-07-12 13:46:21.000000000 -0400
+++ gdb.new/i386-tdep.c	2009-08-07 12:32:58.000000000 -0400
@@ -3139,6 +3139,74 @@
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.  
+*/  
+
+static int i386_record_floats (struct gdbarch *gdbarch,  
+                               struct i386_record_s *ir,  
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to 
+     happen.  Currently we store st0-st7 registers, but we need not store all 
+     registers all the time, in future we use ftag register and record only 
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	      {
+	      if (record_arch_list_add_reg (ir->regcache, i))
+	        return -1;
+	      }
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) && 
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  if(I386_SAVE_FPU_ENV != iregnum)
+    {
+    for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+      if (record_arch_list_add_reg (ir->regcache, i))
+        return -1;
+      }    
+    }             
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3153,6 +3221,7 @@
   uint32_t tmpu32;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   memset (&ir, 0, sizeof (struct i386_record_s));
   ir.regcache = regcache;
@@ -4188,8 +4257,7 @@
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4203,45 +4271,56 @@
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory.  */
 	  uint32_t addr;
 
 	  if (i386_record_lea_modrm_addr (&ir, &addr))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+              /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+              /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4250,6 +4329,7 @@
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d: 
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4258,9 +4338,14 @@
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c: 
+            case 0x3d: 
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4274,6 +4359,7 @@
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4284,15 +4370,49 @@
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (addr, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (addr, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (addr, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */  
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4302,11 +4422,21 @@
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4329,6 +4459,9 @@
 	    case 0x3e:
 	      if (record_arch_list_add_mem (addr, 10))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x2e:
 	      if (ir.dflag)
@@ -4345,10 +4478,17 @@
 		}
 	      if (record_arch_list_add_mem (addr, 80))
 		return -1;
+              /* Insn fsave.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (addr, 8))
 		return -1;
+              /* Ins fistp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4357,8 +4497,211 @@
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */     
+      else
+        { 
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;	
+	      break;
+	    case 0xd9:    
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;	
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;	
+		      /* If only st(0) is changing, then we have already 
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;	                      
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir, 
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;	 
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4775,12 +5118,18 @@
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;     
       break;
 
       /* int3 */

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-05  1:34         ` Michael Snyder
@ 2009-08-05 13:48           ` paawan oza
  0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-05 13:48 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, gdb-patches


Hi Hui and Michael,

Sure, I will preserve it. I modify the code and preserve it.
I will send you the updated patch soon.

this modification does not affect the core functionality, but as you suggested, we are debugger, and should revert all register back.

thank you for your inputs.
Regards,
Oza.


--- On Wed, 8/5/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Wednesday, August 5, 2009, 7:03 AM
> paawan oza wrote:
> > Hi Hui,
> > 
> > please find my analysis as follows.
> > 
> > following are the registers which you may find it
> different.
> > 
> > fstat
> > ftag
> > fiseg
> > fioff
> > foseg
> > fooff
> > fop
> > 
> > In my opinion, we do not need to record all these
> registers. because these registers are purly depends on
> instruction's execution status in FPU unit.
> > 
> > 
> > for e.g.
> > fop register stores te last opcode executed by x87 FPU
> unit.
> > fstat register may contain c0, c1, c2, c3 flag
> status...
> > 
> > why we dont need to record, because even if we reply
> the recod...
> > Anyway these register are going to be change by FPU HW
> unit based on any fp insn's nature and its execution. (next
> insn which FPU is going to execute)
> > 
> > so it doesnt make much sense to store it, because even
> if we restore it, FPU unit doesnt use them directly, but FPU
> HW sets them after executing current fp insn. so anyway they
> are going to reset as soon as FPU executes next insn.
> > 
> > but still if you feel that we must record those
> registers because user might want to observe those
> registers, then I can do that.
> > 
> > please let me know you opinion about it.
> 
> It may be that saving the registers is not purely
> necessary, but
> we are not just a simulator -- we are a debugger.  The
> user might
> be confused if he steps backward and sees that the register
> did not
> change.
> 
> So I think we should preserve it and revert it.
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 17:59       ` paawan oza
  2009-08-05  1:29         ` Hui Zhu
@ 2009-08-05  1:34         ` Michael Snyder
  2009-08-05 13:48           ` paawan oza
  1 sibling, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-08-05  1:34 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, gdb-patches

paawan oza wrote:
> Hi Hui,
> 
> please find my analysis as follows.
> 
> following are the registers which you may find it different.
> 
> fstat
> ftag
> fiseg
> fioff
> foseg
> fooff
> fop
> 
> In my opinion, we do not need to record all these registers. because these registers are purly depends on instruction's execution status in FPU unit.
> 
> 
> for e.g.
> fop register stores te last opcode executed by x87 FPU unit.
> fstat register may contain c0, c1, c2, c3 flag status...
> 
> why we dont need to record, because even if we reply the recod...
> Anyway these register are going to be change by FPU HW unit based on any fp insn's nature and its execution. (next insn which FPU is going to execute)
> 
> so it doesnt make much sense to store it, because even if we restore it, FPU unit doesnt use them directly, but FPU HW sets them after executing current fp insn. so anyway they are going to reset as soon as FPU executes next insn.
> 
> but still if you feel that we must record those registers because user might want to observe those registers, then I can do that.
> 
> please let me know you opinion about it.

It may be that saving the registers is not purely necessary, but
we are not just a simulator -- we are a debugger.  The user might
be confused if he steps backward and sees that the register did not
change.

So I think we should preserve it and revert it.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 17:59       ` paawan oza
@ 2009-08-05  1:29         ` Hui Zhu
  2009-08-05  1:34         ` Michael Snyder
  1 sibling, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-08-05  1:29 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches

I think replay all register is better.

Thanks,
Hui


On Wed, Aug 5, 2009 at 01:59, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi Hui,
>
> please find my analysis as follows.
>
> following are the registers which you may find it different.
>
> fstat
> ftag
> fiseg
> fioff
> foseg
> fooff
> fop
>
> In my opinion, we do not need to record all these registers. because these registers are purly depends on instruction's execution status in FPU unit.
>
>
> for e.g.
> fop register stores te last opcode executed by x87 FPU unit.
> fstat register may contain c0, c1, c2, c3 flag status...
>
> why we dont need to record, because even if we reply the recod...
> Anyway these register are going to be change by FPU HW unit based on any fp insn's nature and its execution. (next insn which FPU is going to execute)
>
> so it doesnt make much sense to store it, because even if we restore it, FPU unit doesnt use them directly, but FPU HW sets them after executing current fp insn. so anyway they are going to reset as soon as FPU executes next insn.
>
> but still if you feel that we must record those registers because user might want to observe those registers, then I can do that.
>
> please let me know you opinion about it.
>
> Regards,
> Oza.
>
> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Tuesday, August 4, 2009, 8:13 PM
>> ./gdb ./a.out
>> GNU gdb (GDB) 6.8.50.20090804-cvs
>> Copyright (C) 2009 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and
>> redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.
>> Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> Setting up the environment for debugging gdb.
>> Function "internal_error" not defined.
>> Make breakpoint pending on future shared library load? (y
>> or [n])
>> [answered N; input not from terminal]
>> Function "info_command" not defined.
>> Make breakpoint pending on future shared library load? (y
>> or [n])
>> [answered N; input not from terminal]
>> /home/teawater/gdb/rec/bgdbno/gdb/.gdbinit:8: Error in
>> sourced command file:
>> No breakpoint number 0.
>> (gdb) start
>> During symbol reading, DW_AT_name missing from
>> DW_TAG_base_type.
>> Temporary breakpoint 1 at 0x8048c74: file 1.c, line 197.
>> Starting program: /home/teawater/gdb/rec/bgdbno/gdb/a.out
>>
>> Temporary breakpoint 1, main () at 1.c:197
>> 197       init_floats();
>> (gdb) record
>> (gdb) info all-registers
>> eax
>> 0x1    1
>> ecx
>> 0xbffff780    -1073744000
>> edx
>> 0xbffff7a0    -1073743968
>> ebx
>> 0xb7f9eff4    -1208356876
>> esp
>> 0xbffff760    0xbffff760
>> ebp
>> 0xbffff768    0xbffff768
>> esi
>> 0xb7ffece0    -1207964448
>> edi
>> 0x0    0
>> eip
>> 0x8048c74    0x8048c74 <main+17>
>> eflags
>>    0x200286    [ PF SF IF ID
>> ]
>> cs
>>    0x73    115
>> ss
>>    0x7b    123
>> ds
>>    0x7b    123
>> es
>>    0x7b    123
>> fs
>>    0x0    0
>> gs
>>    0x33    51
>> st0
>> 0    (raw 0x00000000000000000000)
>> st1
>> 0    (raw 0x00000000000000000000)
>> st2
>> 0    (raw 0x00000000000000000000)
>> st3
>> 0    (raw 0x00000000000000000000)
>> st4
>> 0    (raw 0x00000000000000000000)
>> st5
>> 0    (raw 0x00000000000000000000)
>> st6
>> 0    (raw 0x00000000000000000000)
>> st7
>> 0    (raw 0x00000000000000000000)
>> fctrl
>> 0x37f    895
>> fstat
>> 0x0    0
>> ftag
>>    0xffff    65535
>> fiseg
>> 0x0    0
>> fioff
>> 0x0    0
>> foseg
>> 0x0    0
>> fooff
>> 0x0    0
>> fop
>> 0x0    0
>> xmm0           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm1           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>> ---Type <return> to continue, or q <return> to
>> quit---
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm2           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm3           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm4           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm5           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm6           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm7           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> mxcsr
>> 0x1f80    [ IM DM ZM OM UM PM ]
>> mm0            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm1            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm2            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm3            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm4            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm5            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm6            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm7            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> (gdb)
>> (gdb) c
>> Continuing.
>> result is 369.438751
>> result is 10.320001
>> result is 23.008301
>> result is 0.000000
>> result is 10.450000
>> result is 10.776012
>> result is 495830.968750
>> result is -181.778748
>> result is 12.525923
>> result is 2.195619
>> result is 5.055601
>> result is inf
>> result is inf
>> result is -0.988032
>> result is 0.154251
>> result is -6.405331
>> result is 1.537475
>> The next instruction is syscall exit_group.  It will
>> make the program
>> exit.  Do you want to stop the program?([y] or n)
>> Process record: inferior program stopped.
>>
>> Program received signal SIGTRAP, Trace/breakpoint trap.
>> 0xb7fe3405 in __kernel_vsyscall ()
>> (gdb) rc
>> Continuing.
>>
>> No more reverse-execution history.
>> main () at 1.c:197
>> 197       init_floats();
>> (gdb) info all-registers
>> eax
>> 0x1    1
>> ecx
>> 0xbffff780    -1073744000
>> edx
>> 0xbffff7a0    -1073743968
>> ebx
>> 0xb7f9eff4    -1208356876
>> esp
>> 0xbffff760    0xbffff760
>> ebp
>> 0xbffff768    0xbffff768
>> esi
>> 0xb7ffece0    -1207964448
>> edi
>> 0x0    0
>> eip
>> 0x8048c74    0x8048c74 <main+17>
>> eflags
>>    0x200286    [ PF SF IF ID
>> ]
>> cs
>>    0x73    115
>> ss
>>    0x7b    123
>> ds
>>    0x7b    123
>> es
>>    0x7b    123
>> fs
>>    0x0    0
>> gs
>>    0x33    51
>> st0
>> 0    (raw 0x00000000000000000000)
>> st1
>> 0    (raw 0x00000000000000000000)
>> st2
>> 0    (raw 0x00000000000000000000)
>> st3
>> 0    (raw 0x00000000000000000000)
>> st4
>> 0    (raw 0x00000000000000000000)
>> st5
>> 0    (raw 0x00000000000000000000)
>> st6
>> 0    (raw 0x00000000000000000000)
>> st7
>> 0    (raw 0x00000000000000000000)
>> fctrl
>> 0x37f    895
>> fstat
>> 0x6069    24681
>> ftag
>>    0x13f    319
>> fiseg
>> 0x73    115
>> fioff
>> 0x8048bfd    134515709
>> foseg
>> 0x7b    123
>> fooff
>> 0x0    0
>> fop
>> 0x2e9    745
>> xmm0           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm1           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>> ---Type <return> to continue, or q <return> to
>> quit---
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm2           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm3           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm4           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm5           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm6           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> xmm7           {v4_float
>> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
>> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
>> {0x0, 0x0, 0x0,
>>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
>> 0x0, 0x0, 0x0},
>> v2_int64 = {0x0, 0x0}, uint128 =
>> 0x00000000000000000000000000000000}
>> mxcsr
>> 0x1f80    [ IM DM ZM OM UM PM ]
>> mm0            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm1            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm2            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm3            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm4            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm5            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm6            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> mm7            {uint64 = 0x0,
>> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
>> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
>> 0x0, 0x0}}
>> (gdb)
>>
>>
>> On Tue, Aug 4, 2009 at 22:25, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >
>> > Hi Hui,
>> >
>> > tested following line.
>> > line 54:
>> > result = fmodf(no2,no1);
>> >
>> > please see the log below. all registers are same.
>> >
>> >
>> ******************************************************************
>> > (gdb) n
>> > 52        printf("result is %f\n",result);
>> > (gdb) n
>> > result is 369.438751
>> > 54        result = fmodf(no2,no1);
>> > (gdb) info all-registers
>> > st0            0        (raw
>> 0x00000000000000000000)
>> > st1            0        (raw
>> 0x00000000000000000000)
>> > st2            0        (raw
>> 0x00000000000000000000)
>> > st3            0        (raw
>> 0x00000000000000000000)
>> > st4            0        (raw
>> 0x00000000000000000000)
>> > st5            0        (raw
>> 0x00000000000000000000)
>> > st6            88.87999725341796875     (raw
>> 0x4005b1c28f0000000000)
>> > st7            369.438751220703125      (raw
>> 0x4007b8b8290000000000)
>> > fctrl          0x37f    895
>> > fstat          0x20     32
>> > ftag           0xffff   65535
>> > fiseg          0x73     115
>> > fioff          0xb7eccd27       -1209217753
>> > foseg          0x7b     123
>> > fooff          0xbfffc0d4       -1073757996
>> > fop            0x0      0
>> > (gdb) n
>> > 55        printf("result is %f\n",result);
>> > (gdb)
>> > result is 10.320001
>> > 57        resultd = fmod(x,y);
>> > (gdb) reverse-next
>> > 55        printf("result is %f\n",result);
>> > (gdb)
>> > 54        result = fmodf(no2,no1);
>> > (gdb)
>> > 52        printf("result is %f\n",result);
>> > (gdb) info all-registers
>> > st0            0        (raw
>> 0x00000000000000000000)
>> > st1            0        (raw
>> 0x00000000000000000000)
>> > st2            0        (raw
>> 0x00000000000000000000)
>> > st3            0        (raw
>> 0x00000000000000000000)
>> > st4            0        (raw
>> 0x00000000000000000000)
>> > st5            0        (raw
>> 0x00000000000000000000)
>> > st6            88.87999725341796875     (raw
>> 0x4005b1c28f0000000000)
>> > st7            369.43873691558837890625 (raw
>> 0x4007b8b8288800000000)
>> > fctrl          0x37f    895
>> > fstat          0x20     32
>> > ftag           0xffff   65535
>> > fiseg          0x73     115
>> > fioff          0xb7eccd27       -1209217753
>> > foseg          0x7b     123
>> > fooff          0xbfffc0d4       -1073757996
>> > fop            0x0      0
>> > (gdb)
>> >
>> ******************************************************************
>> >
>> > --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
>> wrote:
>> >
>> >> From: Hui Zhu <teawater@gmail.com>
>> >> Subject: Re: final i386.floating.record.patch
>> >> To: "paawan oza" <paawan1982@yahoo.com>
>> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
>> "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>
>> >> Date: Tuesday, August 4, 2009, 7:28 PM
>> >> I think you can do it with youself.
>> >>
>> >> Hui
>> >>
>> >> On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com>
>> >> wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > As I understand you have tried to run the
>> example test
>> >> code which I had sent earlier.
>> >> >
>> >> > please let me know at which c statement (or
>> insn) it
>> >> is causing this ?
>> >> > So I can dig into it more.
>> >> >
>> >> > Thanks & Regards,
>> >> > Oza.
>> >> >
>> >> >
>> >> > --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com>
>> >> wrote:
>> >> >
>> >> >> From: paawan oza <paawan1982@yahoo.com>
>> >> >> Subject: Re: final
>> i386.floating.record.patch
>> >> >> To: "Hui Zhu" <teawater@gmail.com>
>> >> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
>> >> "gdb-patches@sourceware.org"
>> >> <gdb-patches@sourceware.org>
>> >> >> Date: Tuesday, August 4, 2009, 6:32 PM
>> >> >> Hi Hui,
>> >> >> I am not sure which test case (insn)
>> caused
>> >> this.
>> >> >> would you please send me the example (.c
>> file)
>> >> which you
>> >> >> have tried to run ?
>> >> >> please also try to let me know at which
>> insn (at
>> >> which
>> >> >> point it fails).
>> >> >> Regards,
>> >> >> Oza.
>> >> >>
>> >> >> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
>> >> >> wrote:
>> >> >>
>> >> >> > From: Hui Zhu <teawater@gmail.com>
>> >> >> > Subject: Re: final
>> >> i386.floating.record.patch
>> >> >> > To: "paawan oza" <paawan1982@yahoo.com>
>> >> >> > Cc: "Michael Snyder" <msnyder@vmware.com>,
>> >> >> "gdb-patches@sourceware.org"
>> >> >> <gdb-patches@sourceware.org>
>> >> >> > Date: Tuesday, August 4, 2009, 8:49
>> AM
>> >> >> > Hi Paawan,
>> >> >> >
>> >> >> > Thanks for your work.
>> >> >> >
>> >> >> > I do a some test works with the test
>> code
>> >> that you
>> >> >> sent in
>> >> >> > before.
>> >> >> > I get the values of fp reg with
>> command
>> >> "info
>> >> >> > all-registers".
>> >> >> >
>> >> >> > It looks like some fp reg's values
>> not right
>> >> in
>> >> >> replay
>> >> >> > mode.
>> >> >> >
>> >> >> > In record mode they are:
>> >> >> > fctrl
>> >> >> > 0x37f    895
>> >> >> > fstat
>> >> >> > 0x0    0
>> >> >> > ftag
>> >> >> >    0xffff    65535
>> >> >> > fiseg
>> >> >> > 0x0    0
>> >> >> > fioff
>> >> >> > 0x0    0
>> >> >> > ---Type <return> to continue,
>> or q
>> >> >> <return> to
>> >> >> > quit---
>> >> >> > foseg
>> >> >> > 0x0    0
>> >> >> > fooff
>> >> >> > 0x0    0
>> >> >> > fop
>> >> >> > 0x0    0
>> >> >> >
>> >> >> > In replay mode they are:
>> >> >> > fctrl
>> >> >> > 0x37f    895
>> >> >> > fstat
>> >> >> > 0x6069    24681
>> >> >> > ftag
>> >> >> >    0x557f    21887
>> >> >> > fiseg
>> >> >> > 0x73    115
>> >> >> > fioff
>> >> >> > 0x8048bfd    134515709
>> >> >> > ---Type <return> to continue,
>> or q
>> >> >> <return> to
>> >> >> > quit---
>> >> >> > foseg
>> >> >> > 0x7b    123
>> >> >> > fooff
>> >> >> > 0x0    0
>> >> >> > fop
>> >> >> > 0x2e9    745
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > Thanks,
>> >> >> > Hui
>> >> >> >
>> >> >> >
>> >> >> > #include <stdio.h>
>> >> >> > #include <math.h>
>> >> >> > #include <stdlib.h>
>> >> >> >
>> >> >> > /* the test intends to test
>> following insns.
>> >> >> > flds faddp fstps fstpl fldl fxch
>> fabs fdivrp
>> >> fmulp
>> >> >> fsubrp
>> >> >> > fucomp fnstsw fsqrt
>> >> >> > fchs f2xm1 fyl2x fxtract fprem1 fld
>> fdecstp
>> >> fld1
>> >> >> fldl2t
>> >> >> > fldl2e FLDPI
>> >> >> > FLDLG2 FLDLN2
>> >> >> > FLDZ fincstp ffree fptan fpatan
>> fincstp
>> >> fsincos
>> >> >> frndint
>> >> >> > fscale fsin fcos fcmovb
>> >> >> > fcmovbe fcmove fcmovu fcmovnb
>> fcmovnbe fsave
>> >> frstor
>> >> >> fstsw
>> >> >> > */
>> >> >> >
>> >> >> > float no1,no2,no3,no4,no5,no6,no7;
>> >> >> > double x = 100.345, y = 25.7789;
>> >> >> > long double ldx =
>> 88888888888888888888.88,
>> >> ldy =
>> >> >> > 9999999999999999999.99;
>> >> >> > float result,resultd,resultld;
>> >> >> > float *float_memory;
>> >> >> >
>> >> >> > /* initialization of floats */
>> >> >> > void init_floats()
>> >> >> > {
>> >> >> >  no1 = 10.45;
>> >> >> >  no2 = 20.77;
>> >> >> >  no3 = 156.89874646;
>> >> >> >  no4 = 14.56;
>> >> >> >  no5 = 11.11;
>> >> >> >  no6 = 66.77;
>> >> >> >  no7 = 88.88;
>> >> >> >  float_memory =
>> malloc(sizeof(float) * 4);
>> >> >> >  *float_memory = 256.256;
>> >> >> >  *(float_memory + 1) = 356.356;
>> >> >> >  *(float_memory + 2) = 456.456;
>> >> >> >  *(float_memory + 3) = 556.556;
>> >> >> > }
>> >> >> >
>> >> >> > /* marks FPU stack as empty */
>> >> >> > void empty_fpu_stack()
>> >> >> > {
>> >> >> >  asm ("ffree %st(1) \n\t"
>> >> >> >       "ffree %st(2) \n\t"
>> >> >> >       "ffree %st(3) \n\t"
>> >> >> >       "ffree %st(4) \n\t"
>> >> >> >       "ffree %st(5) \n\t"
>> >> >> >       "ffree %st(6) \n\t"
>> >> >> >       "ffree %st(7)");
>> >> >> > }
>> >> >> >
>> >> >> > /* tests floating point arithmatic
>> */
>> >> >> > void test_arith_floats()
>> >> >> > {
>> >> >> >  result = no1 + no2 + no3 + no4 +
>> no5 + no6
>> >> +
>> >> >> no7;
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = fmodf(no2,no1);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  resultd = fmod(x,y);
>> >> >> >  printf("result is %f\n",resultd);
>> >> >> >
>> >> >> >  resultld = fmodl(ldy,ldy);
>> >> >> >  printf("result is
>> %f\n",resultld);
>> >> >> >
>> >> >> >  result = fabsf(no1);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = no3 / no4;
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = no1 * no2 * no3 * no4;
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = no1 - no2 - no3 - no4;
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fchs");
>> >> >> >
>> >> >> >  /* test for f2xm1 */
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("f2xm1");
>> >> >> >
>> >> >> >  asm ("fyl2x");
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fxtract");
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fprem1");
>> >> >> >
>> >> >> >  /* decrement fpu stack pointer
>> only status
>> >> >> register should
>> >> >> > get affected */
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >
>> >> >> >  empty_fpu_stack();
>> >> >> >
>> >> >> >  asm ("fld1");
>> >> >> >  asm ("fldl2t");
>> >> >> >  asm ("fldl2e");
>> >> >> >  asm ("fldpi");
>> >> >> >  asm ("fldlg2");
>> >> >> >  asm ("fldln2");
>> >> >> >  asm ("fldz");
>> >> >> >
>> >> >> >  empty_fpu_stack();
>> >> >> >  /* finishing emptying the stack
>> */
>> >> >> >
>> >> >> >  result = sqrt(no3);
>> >> >> >  printf("result is %f\n",result);
>> >> >> > }
>> >> >> >
>> >> >> > void test_log_exp_floats()
>> >> >> > {
>> >> >> >  result = log10(no3);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = log(no3);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = exp10(no3);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = exp(no3);
>> >> >> >  printf("result is %f\n",result);
>> >> >> > }
>> >> >> >
>> >> >> > void test_trigo_floats()
>> >> >> > {
>> >> >> >  result = sin(30);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = cos(30);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = tan(30);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  result = atan(30);
>> >> >> >  printf("result is %f\n",result);
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fptan");
>> >> >> >
>> >> >> >  /* changes st1 and popping
>> register stack
>> >> */
>> >> >> >  asm ("fpatan");
>> >> >> >
>> >> >> >  asm("fincstp");
>> >> >> >  asm ("fld %0" :
>> :"m"(float_memory));
>> >> >> >  asm ("fsincos");
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("frndint");
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >> >> >  asm ("fscale");
>> >> >> >
>> >> >> >  empty_fpu_stack();
>> >> >> >
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fsin");
>> >> >> >  asm ("fcos");
>> >> >> >
>> >> >> >  /* currently we assume condition
>> likely
>> >> and
>> >> >> always record
>> >> >> > the registers
>> >> >> >  code could be optimized only if
>> the flag is
>> >> set
>> >> >> then
>> >> >> > record */
>> >> >> >  asm ("fld %0" :
>> :"m"(*float_memory));
>> >> >> >  asm ("fld %0" :
>> :"m"(*(float_memory+1)));
>> >> >> >  asm ("fcmovb %st(1), %st");
>> >> >> >  asm ("fcmovbe %st(1), %st");
>> >> >> >  asm ("fcmove %st(1), %st");
>> >> >> >  asm ("fcmovu %st(1), %st");
>> >> >> >  asm ("fcmovnb %st(1), %st");
>> >> >> >  asm ("fcmovnbe %st(1), %st");
>> >> >> >
>> >> >> >  empty_fpu_stack();
>> >> >> >  /* finished emtyping the stack */
>> >> >> > }
>> >> >> >
>> >> >> > void test_compare_floats()
>> >> >> > {
>> >> >> >    ldy =
>> 88888888888888888888.88;
>> >> >> >    if (ldx == ldy)
>> >> >> >      ldy =
>> >> >> > 7777777777777777777777777777.777;
>> >> >> >    else
>> >> >> >      ldy =
>> >> >> > 666666666666666666666666666.666;
>> >> >> > }
>> >> >> >
>> >> >> > /* test loading and saving of FPU
>> environment
>> >> */
>> >> >> > void test_fpu_env()
>> >> >> > {
>> >> >> >  asm ("fsave %0" :
>> "=m"(*float_memory) : );
>> >> >> >  asm ("frstor %0" : :
>> "m"(*float_memory));
>> >> >> >  asm ("fstsw %ax");
>> >> >> > }
>> >> >> >
>> >> >> > int main()
>> >> >> > {
>> >> >> >    init_floats();
>> >> >> >    test_arith_floats();
>> >> >> >    test_log_exp_floats();
>> >> >> >    test_trigo_floats();
>> >> >> >    test_compare_floats();
>> >> >> >    test_fpu_env();
>> >> >> > }
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Mon, Aug 3, 2009 at 22:56,
>> paawan
>> >> oza<paawan1982@yahoo.com>
>> >> >> > wrote:
>> >> >> > > Hi,
>> >> >> > >
>> >> >> > > please find the patch attached.
>> I have
>> >> attached
>> >> >> as per
>> >> >> > your suggestion.
>> >> >> > > I am attaching it from opera
>> browser.
>> >> >> > >
>> >> >> > > Regards,
>> >> >> > > Oza.
>> >> >> > >
>> >> >> > > --- On Thu, 7/30/09, Michael
>> Snyder
>> >> <msnyder@vmware.com>
>> >> >> > wrote:
>> >> >> > >
>> >> >> > >> From: Michael Snyder <msnyder@vmware.com>
>> >> >> > >> Subject: Re: final
>> >> >> i386.floating.record.patch
>> >> >> > >> To: "paawan oza" <paawan1982@yahoo.com>
>> >> >> > >> Cc: "gdb-patches@sourceware.org"
>> >> >> > <gdb-patches@sourceware.org>
>> >> >> > >> Date: Thursday, July 30,
>> 2009, 11:31
>> >> PM
>> >> >> > >> paawan oza wrote:
>> >> >> > >> > Hi,
>> >> >> > >> >
>> >> >> > >> > please find my answers
>> below.
>> >> >> > >> >
>> >> >> > >> >  1) Are you using a
>> Windows
>> >> machine to
>> >> >> send
>> >> >> > your
>> >> >> > >> >  emails?  If so,
>> >> >> > >> >  is it possible that
>> there is
>> >> a
>> >> >> Unix/Linux
>> >> >> > >> machine you could
>> >> >> > >> >  try
>> >> >> > >> >  sending from?
>> Your
>> >> attachments look
>> >> >> OK
>> >> >> > for
>> >> >> > >> me, but
>> >> >> > >> >  some people
>> >> >> > >> >  seem to have had
>> problems
>> >> with them.
>> >> >> > >> >
>> >> >> > >> > Oza : I used to send
>> all from
>> >> windows
>> >> >> till
>> >> >> > now.
>> >> >> > >> > but this patch I sent
>> it from
>> >> >> Linux...from
>> >> >> > opera.
>> >> >> > >> >   2) And are you
>> using
>> >> cut-and-paste
>> >> >> to
>> >> >> > >> insert the patches
>> >> >> > >> >  into the
>> >> >> > >> >  body of your
>> email?  That
>> >> would
>> >> >> certainly
>> >> >> > >> cause
>> >> >> > >> >  problems, because
>> >> >> > >> >  tabs might be
>> changed into
>> >> spaces
>> >> >> (which
>> >> >> > is
>> >> >> > >> exactly what
>> >> >> > >> >  was
>> >> >> > >> >  causing patch to
>> fail for me
>> >> today).
>> >> >> > >> >  Oza: yes I am using
>> >> copy-paste....I
>> >> >> dont
>> >> >> > know
>> >> >> > >> any-other way.
>> >> >> > >> > because attachmenet
>> are not
>> >> welcome, so
>> >> >> I am
>> >> >> > not sure
>> >> >> > >> how I could proceed with
>> this.
>> >> >> > >>
>> >> >> > >> It's not that attachments
>> are not
>> >> welcome.
>> >> >> > >> There are various binary
>> encodings
>> >> for
>> >> >> > attachments, and
>> >> >> > >> some of those binary
>> encodings are
>> >> not
>> >> >> welcome.
>> >> >> > I
>> >> >> > >> think
>> >> >> > >> because there's no
>> open-source way
>> >> of
>> >> >> decoding
>> >> >> > them.
>> >> >> > >>
>> >> >> > >> If you look at the list,
>> you'll see
>> >> that
>> >> >> > attachments are
>> >> >> > >> used a lot.
>> >> >> > >>
>> >> >> > >> Copy-and-paste, though, in
>> general
>> >> will not
>> >> >> work,
>> >> >> > because
>> >> >> > >> it
>> >> >> > >> usually changes tabs into
>> spaces,
>> >> which ruins
>> >> >> a
>> >> >> > patch.
>> >> >> > >>
>> >> >> > >>
>> >> >> > >> > I will send you
>> updated
>> >> patch.....may be
>> >> >> I
>> >> >> > might have
>> >> >> > >> mistaken of old gdb file.
>> sorry for
>> >> >> incovenience.
>> >> >> > >>
>> >> >> > >> I think it was just the
>> >> tabs-to-spaces
>> >> >> issue.
>> >> >> > >> Why don't you try sending
>> an
>> >> attachment from
>> >> >> > Opera?
>> >> >> > >>
>> >> >> > >>
>> >> >> > >
>> >> >> > >
>> >> >> > >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> >
>> >>
>> >
>> >
>> >
>> >
>>
>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 14:43     ` Hui Zhu
@ 2009-08-04 17:59       ` paawan oza
  2009-08-05  1:29         ` Hui Zhu
  2009-08-05  1:34         ` Michael Snyder
  0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-08-04 17:59 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches


Hi Hui,

please find my analysis as follows.

following are the registers which you may find it different.

fstat
ftag 
fiseg
fioff
foseg
fooff
fop  

In my opinion, we do not need to record all these registers. because these registers are purly depends on instruction's execution status in FPU unit.


for e.g. 
fop register stores te last opcode executed by x87 FPU unit.
fstat register may contain c0, c1, c2, c3 flag status...

why we dont need to record, because even if we reply the recod...
Anyway these register are going to be change by FPU HW unit based on any fp insn's nature and its execution. (next insn which FPU is going to execute)

so it doesnt make much sense to store it, because even if we restore it, FPU unit doesnt use them directly, but FPU HW sets them after executing current fp insn. so anyway they are going to reset as soon as FPU executes next insn.

but still if you feel that we must record those registers because user might want to observe those registers, then I can do that. 

please let me know you opinion about it.

Regards,
Oza.

--- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, August 4, 2009, 8:13 PM
> ./gdb ./a.out
> GNU gdb (GDB) 6.8.50.20090804-cvs
> Copyright (C) 2009 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and
> redistribute it.
> There is NO WARRANTY, to the extent permitted by law. 
> Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "i686-pc-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Setting up the environment for debugging gdb.
> Function "internal_error" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n])
> [answered N; input not from terminal]
> Function "info_command" not defined.
> Make breakpoint pending on future shared library load? (y
> or [n])
> [answered N; input not from terminal]
> /home/teawater/gdb/rec/bgdbno/gdb/.gdbinit:8: Error in
> sourced command file:
> No breakpoint number 0.
> (gdb) start
> During symbol reading, DW_AT_name missing from
> DW_TAG_base_type.
> Temporary breakpoint 1 at 0x8048c74: file 1.c, line 197.
> Starting program: /home/teawater/gdb/rec/bgdbno/gdb/a.out
> 
> Temporary breakpoint 1, main () at 1.c:197
> 197       init_floats();
> (gdb) record
> (gdb) info all-registers
> eax           
> 0x1    1
> ecx           
> 0xbffff780    -1073744000
> edx           
> 0xbffff7a0    -1073743968
> ebx           
> 0xb7f9eff4    -1208356876
> esp           
> 0xbffff760    0xbffff760
> ebp           
> 0xbffff768    0xbffff768
> esi           
> 0xb7ffece0    -1207964448
> edi           
> 0x0    0
> eip           
> 0x8048c74    0x8048c74 <main+17>
> eflags     
>    0x200286    [ PF SF IF ID
> ]
> cs         
>    0x73    115
> ss         
>    0x7b    123
> ds         
>    0x7b    123
> es         
>    0x7b    123
> fs         
>    0x0    0
> gs         
>    0x33    51
> st0           
> 0    (raw 0x00000000000000000000)
> st1           
> 0    (raw 0x00000000000000000000)
> st2           
> 0    (raw 0x00000000000000000000)
> st3           
> 0    (raw 0x00000000000000000000)
> st4           
> 0    (raw 0x00000000000000000000)
> st5           
> 0    (raw 0x00000000000000000000)
> st6           
> 0    (raw 0x00000000000000000000)
> st7           
> 0    (raw 0x00000000000000000000)
> fctrl         
> 0x37f    895
> fstat         
> 0x0    0
> ftag       
>    0xffff    65535
> fiseg         
> 0x0    0
> fioff         
> 0x0    0
> foseg         
> 0x0    0
> fooff         
> 0x0    0
> fop           
> 0x0    0
> xmm0           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm1           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
> ---Type <return> to continue, or q <return> to
> quit---
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm2           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm3           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm4           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm5           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm6           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm7           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> mxcsr         
> 0x1f80    [ IM DM ZM OM UM PM ]
> mm0            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm1            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm2            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm3            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm4            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm5            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm6            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm7            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> (gdb)
> (gdb) c
> Continuing.
> result is 369.438751
> result is 10.320001
> result is 23.008301
> result is 0.000000
> result is 10.450000
> result is 10.776012
> result is 495830.968750
> result is -181.778748
> result is 12.525923
> result is 2.195619
> result is 5.055601
> result is inf
> result is inf
> result is -0.988032
> result is 0.154251
> result is -6.405331
> result is 1.537475
> The next instruction is syscall exit_group.  It will
> make the program
> exit.  Do you want to stop the program?([y] or n)
> Process record: inferior program stopped.
> 
> Program received signal SIGTRAP, Trace/breakpoint trap.
> 0xb7fe3405 in __kernel_vsyscall ()
> (gdb) rc
> Continuing.
> 
> No more reverse-execution history.
> main () at 1.c:197
> 197       init_floats();
> (gdb) info all-registers
> eax           
> 0x1    1
> ecx           
> 0xbffff780    -1073744000
> edx           
> 0xbffff7a0    -1073743968
> ebx           
> 0xb7f9eff4    -1208356876
> esp           
> 0xbffff760    0xbffff760
> ebp           
> 0xbffff768    0xbffff768
> esi           
> 0xb7ffece0    -1207964448
> edi           
> 0x0    0
> eip           
> 0x8048c74    0x8048c74 <main+17>
> eflags     
>    0x200286    [ PF SF IF ID
> ]
> cs         
>    0x73    115
> ss         
>    0x7b    123
> ds         
>    0x7b    123
> es         
>    0x7b    123
> fs         
>    0x0    0
> gs         
>    0x33    51
> st0           
> 0    (raw 0x00000000000000000000)
> st1           
> 0    (raw 0x00000000000000000000)
> st2           
> 0    (raw 0x00000000000000000000)
> st3           
> 0    (raw 0x00000000000000000000)
> st4           
> 0    (raw 0x00000000000000000000)
> st5           
> 0    (raw 0x00000000000000000000)
> st6           
> 0    (raw 0x00000000000000000000)
> st7           
> 0    (raw 0x00000000000000000000)
> fctrl         
> 0x37f    895
> fstat         
> 0x6069    24681
> ftag       
>    0x13f    319
> fiseg         
> 0x73    115
> fioff         
> 0x8048bfd    134515709
> foseg         
> 0x7b    123
> fooff         
> 0x0    0
> fop           
> 0x2e9    745
> xmm0           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm1           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
> ---Type <return> to continue, or q <return> to
> quit---
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm2           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm3           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm4           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm5           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm6           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> xmm7           {v4_float
> = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
> 0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 =
> {0x0, 0x0, 0x0,
>     0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0,
> 0x0, 0x0, 0x0},
> v2_int64 = {0x0, 0x0}, uint128 =
> 0x00000000000000000000000000000000}
> mxcsr         
> 0x1f80    [ IM DM ZM OM UM PM ]
> mm0            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm1            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm2            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm3            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm4            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm5            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm6            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> mm7            {uint64 = 0x0,
> v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
> 0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
> 0x0, 0x0}}
> (gdb)
> 
> 
> On Tue, Aug 4, 2009 at 22:25, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi Hui,
> >
> > tested following line.
> > line 54:
> > result = fmodf(no2,no1);
> >
> > please see the log below. all registers are same.
> >
> >
> ******************************************************************
> > (gdb) n
> > 52        printf("result is %f\n",result);
> > (gdb) n
> > result is 369.438751
> > 54        result = fmodf(no2,no1);
> > (gdb) info all-registers
> > st0            0        (raw
> 0x00000000000000000000)
> > st1            0        (raw
> 0x00000000000000000000)
> > st2            0        (raw
> 0x00000000000000000000)
> > st3            0        (raw
> 0x00000000000000000000)
> > st4            0        (raw
> 0x00000000000000000000)
> > st5            0        (raw
> 0x00000000000000000000)
> > st6            88.87999725341796875     (raw
> 0x4005b1c28f0000000000)
> > st7            369.438751220703125      (raw
> 0x4007b8b8290000000000)
> > fctrl          0x37f    895
> > fstat          0x20     32
> > ftag           0xffff   65535
> > fiseg          0x73     115
> > fioff          0xb7eccd27       -1209217753
> > foseg          0x7b     123
> > fooff          0xbfffc0d4       -1073757996
> > fop            0x0      0
> > (gdb) n
> > 55        printf("result is %f\n",result);
> > (gdb)
> > result is 10.320001
> > 57        resultd = fmod(x,y);
> > (gdb) reverse-next
> > 55        printf("result is %f\n",result);
> > (gdb)
> > 54        result = fmodf(no2,no1);
> > (gdb)
> > 52        printf("result is %f\n",result);
> > (gdb) info all-registers
> > st0            0        (raw
> 0x00000000000000000000)
> > st1            0        (raw
> 0x00000000000000000000)
> > st2            0        (raw
> 0x00000000000000000000)
> > st3            0        (raw
> 0x00000000000000000000)
> > st4            0        (raw
> 0x00000000000000000000)
> > st5            0        (raw
> 0x00000000000000000000)
> > st6            88.87999725341796875     (raw
> 0x4005b1c28f0000000000)
> > st7            369.43873691558837890625 (raw
> 0x4007b8b8288800000000)
> > fctrl          0x37f    895
> > fstat          0x20     32
> > ftag           0xffff   65535
> > fiseg          0x73     115
> > fioff          0xb7eccd27       -1209217753
> > foseg          0x7b     123
> > fooff          0xbfffc0d4       -1073757996
> > fop            0x0      0
> > (gdb)
> >
> ******************************************************************
> >
> > --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >
> >> From: Hui Zhu <teawater@gmail.com>
> >> Subject: Re: final i386.floating.record.patch
> >> To: "paawan oza" <paawan1982@yahoo.com>
> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Tuesday, August 4, 2009, 7:28 PM
> >> I think you can do it with youself.
> >>
> >> Hui
> >>
> >> On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com>
> >> wrote:
> >> >
> >> > Hi,
> >> >
> >> > As I understand you have tried to run the
> example test
> >> code which I had sent earlier.
> >> >
> >> > please let me know at which c statement (or
> insn) it
> >> is causing this ?
> >> > So I can dig into it more.
> >> >
> >> > Thanks & Regards,
> >> > Oza.
> >> >
> >> >
> >> > --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com>
> >> wrote:
> >> >
> >> >> From: paawan oza <paawan1982@yahoo.com>
> >> >> Subject: Re: final
> i386.floating.record.patch
> >> >> To: "Hui Zhu" <teawater@gmail.com>
> >> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
> >> "gdb-patches@sourceware.org"
> >> <gdb-patches@sourceware.org>
> >> >> Date: Tuesday, August 4, 2009, 6:32 PM
> >> >> Hi Hui,
> >> >> I am not sure which test case (insn) 
> caused
> >> this.
> >> >> would you please send me the example (.c
> file)
> >> which you
> >> >> have tried to run ?
> >> >> please also try to let me know at which
> insn (at
> >> which
> >> >> point it fails).
> >> >> Regards,
> >> >> Oza.
> >> >>
> >> >> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
> >> >> wrote:
> >> >>
> >> >> > From: Hui Zhu <teawater@gmail.com>
> >> >> > Subject: Re: final
> >> i386.floating.record.patch
> >> >> > To: "paawan oza" <paawan1982@yahoo.com>
> >> >> > Cc: "Michael Snyder" <msnyder@vmware.com>,
> >> >> "gdb-patches@sourceware.org"
> >> >> <gdb-patches@sourceware.org>
> >> >> > Date: Tuesday, August 4, 2009, 8:49
> AM
> >> >> > Hi Paawan,
> >> >> >
> >> >> > Thanks for your work.
> >> >> >
> >> >> > I do a some test works with the test
> code
> >> that you
> >> >> sent in
> >> >> > before.
> >> >> > I get the values of fp reg with
> command
> >> "info
> >> >> > all-registers".
> >> >> >
> >> >> > It looks like some fp reg's values
> not right
> >> in
> >> >> replay
> >> >> > mode.
> >> >> >
> >> >> > In record mode they are:
> >> >> > fctrl
> >> >> > 0x37f    895
> >> >> > fstat
> >> >> > 0x0    0
> >> >> > ftag
> >> >> >    0xffff    65535
> >> >> > fiseg
> >> >> > 0x0    0
> >> >> > fioff
> >> >> > 0x0    0
> >> >> > ---Type <return> to continue,
> or q
> >> >> <return> to
> >> >> > quit---
> >> >> > foseg
> >> >> > 0x0    0
> >> >> > fooff
> >> >> > 0x0    0
> >> >> > fop
> >> >> > 0x0    0
> >> >> >
> >> >> > In replay mode they are:
> >> >> > fctrl
> >> >> > 0x37f    895
> >> >> > fstat
> >> >> > 0x6069    24681
> >> >> > ftag
> >> >> >    0x557f    21887
> >> >> > fiseg
> >> >> > 0x73    115
> >> >> > fioff
> >> >> > 0x8048bfd    134515709
> >> >> > ---Type <return> to continue,
> or q
> >> >> <return> to
> >> >> > quit---
> >> >> > foseg
> >> >> > 0x7b    123
> >> >> > fooff
> >> >> > 0x0    0
> >> >> > fop
> >> >> > 0x2e9    745
> >> >> >
> >> >> >
> >> >> >
> >> >> > Thanks,
> >> >> > Hui
> >> >> >
> >> >> >
> >> >> > #include <stdio.h>
> >> >> > #include <math.h>
> >> >> > #include <stdlib.h>
> >> >> >
> >> >> > /* the test intends to test
> following insns.
> >> >> > flds faddp fstps fstpl fldl fxch
> fabs fdivrp
> >> fmulp
> >> >> fsubrp
> >> >> > fucomp fnstsw fsqrt
> >> >> > fchs f2xm1 fyl2x fxtract fprem1 fld
> fdecstp
> >> fld1
> >> >> fldl2t
> >> >> > fldl2e FLDPI
> >> >> > FLDLG2 FLDLN2
> >> >> > FLDZ fincstp ffree fptan fpatan
> fincstp
> >> fsincos
> >> >> frndint
> >> >> > fscale fsin fcos fcmovb
> >> >> > fcmovbe fcmove fcmovu fcmovnb
> fcmovnbe fsave
> >> frstor
> >> >> fstsw
> >> >> > */
> >> >> >
> >> >> > float no1,no2,no3,no4,no5,no6,no7;
> >> >> > double x = 100.345, y = 25.7789;
> >> >> > long double ldx =
> 88888888888888888888.88,
> >> ldy =
> >> >> > 9999999999999999999.99;
> >> >> > float result,resultd,resultld;
> >> >> > float *float_memory;
> >> >> >
> >> >> > /* initialization of floats */
> >> >> > void init_floats()
> >> >> > {
> >> >> >  no1 = 10.45;
> >> >> >  no2 = 20.77;
> >> >> >  no3 = 156.89874646;
> >> >> >  no4 = 14.56;
> >> >> >  no5 = 11.11;
> >> >> >  no6 = 66.77;
> >> >> >  no7 = 88.88;
> >> >> >  float_memory =
> malloc(sizeof(float) * 4);
> >> >> >  *float_memory = 256.256;
> >> >> >  *(float_memory + 1) = 356.356;
> >> >> >  *(float_memory + 2) = 456.456;
> >> >> >  *(float_memory + 3) = 556.556;
> >> >> > }
> >> >> >
> >> >> > /* marks FPU stack as empty */
> >> >> > void empty_fpu_stack()
> >> >> > {
> >> >> >  asm ("ffree %st(1) \n\t"
> >> >> >       "ffree %st(2) \n\t"
> >> >> >       "ffree %st(3) \n\t"
> >> >> >       "ffree %st(4) \n\t"
> >> >> >       "ffree %st(5) \n\t"
> >> >> >       "ffree %st(6) \n\t"
> >> >> >       "ffree %st(7)");
> >> >> > }
> >> >> >
> >> >> > /* tests floating point arithmatic
> */
> >> >> > void test_arith_floats()
> >> >> > {
> >> >> >  result = no1 + no2 + no3 + no4 +
> no5 + no6
> >> +
> >> >> no7;
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = fmodf(no2,no1);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  resultd = fmod(x,y);
> >> >> >  printf("result is %f\n",resultd);
> >> >> >
> >> >> >  resultld = fmodl(ldy,ldy);
> >> >> >  printf("result is
> %f\n",resultld);
> >> >> >
> >> >> >  result = fabsf(no1);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = no3 / no4;
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = no1 * no2 * no3 * no4;
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = no1 - no2 - no3 - no4;
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fchs");
> >> >> >
> >> >> >  /* test for f2xm1 */
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("f2xm1");
> >> >> >
> >> >> >  asm ("fyl2x");
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fxtract");
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fprem1");
> >> >> >
> >> >> >  /* decrement fpu stack pointer
> only status
> >> >> register should
> >> >> > get affected */
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >
> >> >> >  empty_fpu_stack();
> >> >> >
> >> >> >  asm ("fld1");
> >> >> >  asm ("fldl2t");
> >> >> >  asm ("fldl2e");
> >> >> >  asm ("fldpi");
> >> >> >  asm ("fldlg2");
> >> >> >  asm ("fldln2");
> >> >> >  asm ("fldz");
> >> >> >
> >> >> >  empty_fpu_stack();
> >> >> >  /* finishing emptying the stack
> */
> >> >> >
> >> >> >  result = sqrt(no3);
> >> >> >  printf("result is %f\n",result);
> >> >> > }
> >> >> >
> >> >> > void test_log_exp_floats()
> >> >> > {
> >> >> >  result = log10(no3);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = log(no3);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = exp10(no3);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = exp(no3);
> >> >> >  printf("result is %f\n",result);
> >> >> > }
> >> >> >
> >> >> > void test_trigo_floats()
> >> >> > {
> >> >> >  result = sin(30);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = cos(30);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = tan(30);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  result = atan(30);
> >> >> >  printf("result is %f\n",result);
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fptan");
> >> >> >
> >> >> >  /* changes st1 and popping
> register stack
> >> */
> >> >> >  asm ("fpatan");
> >> >> >
> >> >> >  asm("fincstp");
> >> >> >  asm ("fld %0" :
> :"m"(float_memory));
> >> >> >  asm ("fsincos");
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("frndint");
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fld %0" :
> :"m"(*(float_memory+1)));
> >> >> >  asm ("fscale");
> >> >> >
> >> >> >  empty_fpu_stack();
> >> >> >
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fsin");
> >> >> >  asm ("fcos");
> >> >> >
> >> >> >  /* currently we assume condition
> likely
> >> and
> >> >> always record
> >> >> > the registers
> >> >> >  code could be optimized only if
> the flag is
> >> set
> >> >> then
> >> >> > record */
> >> >> >  asm ("fld %0" :
> :"m"(*float_memory));
> >> >> >  asm ("fld %0" :
> :"m"(*(float_memory+1)));
> >> >> >  asm ("fcmovb %st(1), %st");
> >> >> >  asm ("fcmovbe %st(1), %st");
> >> >> >  asm ("fcmove %st(1), %st");
> >> >> >  asm ("fcmovu %st(1), %st");
> >> >> >  asm ("fcmovnb %st(1), %st");
> >> >> >  asm ("fcmovnbe %st(1), %st");
> >> >> >
> >> >> >  empty_fpu_stack();
> >> >> >  /* finished emtyping the stack */
> >> >> > }
> >> >> >
> >> >> > void test_compare_floats()
> >> >> > {
> >> >> >    ldy =
> 88888888888888888888.88;
> >> >> >    if (ldx == ldy)
> >> >> >      ldy =
> >> >> > 7777777777777777777777777777.777;
> >> >> >    else
> >> >> >      ldy =
> >> >> > 666666666666666666666666666.666;
> >> >> > }
> >> >> >
> >> >> > /* test loading and saving of FPU
> environment
> >> */
> >> >> > void test_fpu_env()
> >> >> > {
> >> >> >  asm ("fsave %0" :
> "=m"(*float_memory) : );
> >> >> >  asm ("frstor %0" : :
> "m"(*float_memory));
> >> >> >  asm ("fstsw %ax");
> >> >> > }
> >> >> >
> >> >> > int main()
> >> >> > {
> >> >> >    init_floats();
> >> >> >    test_arith_floats();
> >> >> >    test_log_exp_floats();
> >> >> >    test_trigo_floats();
> >> >> >    test_compare_floats();
> >> >> >    test_fpu_env();
> >> >> > }
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Mon, Aug 3, 2009 at 22:56,
> paawan
> >> oza<paawan1982@yahoo.com>
> >> >> > wrote:
> >> >> > > Hi,
> >> >> > >
> >> >> > > please find the patch attached.
> I have
> >> attached
> >> >> as per
> >> >> > your suggestion.
> >> >> > > I am attaching it from opera
> browser.
> >> >> > >
> >> >> > > Regards,
> >> >> > > Oza.
> >> >> > >
> >> >> > > --- On Thu, 7/30/09, Michael
> Snyder
> >> <msnyder@vmware.com>
> >> >> > wrote:
> >> >> > >
> >> >> > >> From: Michael Snyder <msnyder@vmware.com>
> >> >> > >> Subject: Re: final
> >> >> i386.floating.record.patch
> >> >> > >> To: "paawan oza" <paawan1982@yahoo.com>
> >> >> > >> Cc: "gdb-patches@sourceware.org"
> >> >> > <gdb-patches@sourceware.org>
> >> >> > >> Date: Thursday, July 30,
> 2009, 11:31
> >> PM
> >> >> > >> paawan oza wrote:
> >> >> > >> > Hi,
> >> >> > >> >
> >> >> > >> > please find my answers
> below.
> >> >> > >> >
> >> >> > >> >  1) Are you using a
> Windows
> >> machine to
> >> >> send
> >> >> > your
> >> >> > >> >  emails?  If so,
> >> >> > >> >  is it possible that
> there is
> >> a
> >> >> Unix/Linux
> >> >> > >> machine you could
> >> >> > >> >  try
> >> >> > >> >  sending from? 
> Your
> >> attachments look
> >> >> OK
> >> >> > for
> >> >> > >> me, but
> >> >> > >> >  some people
> >> >> > >> >  seem to have had
> problems
> >> with them.
> >> >> > >> >
> >> >> > >> > Oza : I used to send
> all from
> >> windows
> >> >> till
> >> >> > now.
> >> >> > >> > but this patch I sent
> it from
> >> >> Linux...from
> >> >> > opera.
> >> >> > >> >   2) And are you
> using
> >> cut-and-paste
> >> >> to
> >> >> > >> insert the patches
> >> >> > >> >  into the
> >> >> > >> >  body of your
> email?  That
> >> would
> >> >> certainly
> >> >> > >> cause
> >> >> > >> >  problems, because
> >> >> > >> >  tabs might be
> changed into
> >> spaces
> >> >> (which
> >> >> > is
> >> >> > >> exactly what
> >> >> > >> >  was
> >> >> > >> >  causing patch to
> fail for me
> >> today).
> >> >> > >> >  Oza: yes I am using
> >> copy-paste....I
> >> >> dont
> >> >> > know
> >> >> > >> any-other way.
> >> >> > >> > because attachmenet
> are not
> >> welcome, so
> >> >> I am
> >> >> > not sure
> >> >> > >> how I could proceed with
> this.
> >> >> > >>
> >> >> > >> It's not that attachments
> are not
> >> welcome.
> >> >> > >> There are various binary
> encodings
> >> for
> >> >> > attachments, and
> >> >> > >> some of those binary
> encodings are
> >> not
> >> >> welcome.
> >> >> > I
> >> >> > >> think
> >> >> > >> because there's no
> open-source way
> >> of
> >> >> decoding
> >> >> > them.
> >> >> > >>
> >> >> > >> If you look at the list,
> you'll see
> >> that
> >> >> > attachments are
> >> >> > >> used a lot.
> >> >> > >>
> >> >> > >> Copy-and-paste, though, in
> general
> >> will not
> >> >> work,
> >> >> > because
> >> >> > >> it
> >> >> > >> usually changes tabs into
> spaces,
> >> which ruins
> >> >> a
> >> >> > patch.
> >> >> > >>
> >> >> > >>
> >> >> > >> > I will send you
> updated
> >> patch.....may be
> >> >> I
> >> >> > might have
> >> >> > >> mistaken of old gdb file.
> sorry for
> >> >> incovenience.
> >> >> > >>
> >> >> > >> I think it was just the
> >> tabs-to-spaces
> >> >> issue.
> >> >> > >> Why don't you try sending
> an
> >> attachment from
> >> >> > Opera?
> >> >> > >>
> >> >> > >>
> >> >> > >
> >> >> > >
> >> >> > >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 14:26   ` paawan oza
@ 2009-08-04 14:43     ` Hui Zhu
  2009-08-04 17:59       ` paawan oza
  0 siblings, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-08-04 14:43 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches

./gdb ./a.out
GNU gdb (GDB) 6.8.50.20090804-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Setting up the environment for debugging gdb.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "info_command" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
/home/teawater/gdb/rec/bgdbno/gdb/.gdbinit:8: Error in sourced command file:
No breakpoint number 0.
(gdb) start
During symbol reading, DW_AT_name missing from DW_TAG_base_type.
Temporary breakpoint 1 at 0x8048c74: file 1.c, line 197.
Starting program: /home/teawater/gdb/rec/bgdbno/gdb/a.out

Temporary breakpoint 1, main () at 1.c:197
197	   init_floats();
(gdb) record
(gdb) info all-registers
eax            0x1	1
ecx            0xbffff780	-1073744000
edx            0xbffff7a0	-1073743968
ebx            0xb7f9eff4	-1208356876
esp            0xbffff760	0xbffff760
ebp            0xbffff768	0xbffff768
esi            0xb7ffece0	-1207964448
edi            0x0	0
eip            0x8048c74	0x8048c74 <main+17>
eflags         0x200286	[ PF SF IF ID ]
cs             0x73	115
ss             0x7b	123
ds             0x7b	123
es             0x7b	123
fs             0x0	0
gs             0x33	51
st0            0	(raw 0x00000000000000000000)
st1            0	(raw 0x00000000000000000000)
st2            0	(raw 0x00000000000000000000)
st3            0	(raw 0x00000000000000000000)
st4            0	(raw 0x00000000000000000000)
st5            0	(raw 0x00000000000000000000)
st6            0	(raw 0x00000000000000000000)
st7            0	(raw 0x00000000000000000000)
fctrl          0x37f	895
fstat          0x0	0
ftag           0xffff	65535
fiseg          0x0	0
fioff          0x0	0
foseg          0x0	0
fooff          0x0	0
fop            0x0	0
xmm0           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm1           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
---Type <return> to continue, or q <return> to quit---
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm2           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm3           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm4           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm5           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm6           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm7           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
mxcsr          0x1f80	[ IM DM ZM OM UM PM ]
mm0            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm1            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm2            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm3            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm4            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm5            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm6            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm7            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb)
(gdb) c
Continuing.
result is 369.438751
result is 10.320001
result is 23.008301
result is 0.000000
result is 10.450000
result is 10.776012
result is 495830.968750
result is -181.778748
result is 12.525923
result is 2.195619
result is 5.055601
result is inf
result is inf
result is -0.988032
result is 0.154251
result is -6.405331
result is 1.537475
The next instruction is syscall exit_group.  It will make the program
exit.  Do you want to stop the program?([y] or n)
Process record: inferior program stopped.

Program received signal SIGTRAP, Trace/breakpoint trap.
0xb7fe3405 in __kernel_vsyscall ()
(gdb) rc
Continuing.

No more reverse-execution history.
main () at 1.c:197
197	   init_floats();
(gdb) info all-registers
eax            0x1	1
ecx            0xbffff780	-1073744000
edx            0xbffff7a0	-1073743968
ebx            0xb7f9eff4	-1208356876
esp            0xbffff760	0xbffff760
ebp            0xbffff768	0xbffff768
esi            0xb7ffece0	-1207964448
edi            0x0	0
eip            0x8048c74	0x8048c74 <main+17>
eflags         0x200286	[ PF SF IF ID ]
cs             0x73	115
ss             0x7b	123
ds             0x7b	123
es             0x7b	123
fs             0x0	0
gs             0x33	51
st0            0	(raw 0x00000000000000000000)
st1            0	(raw 0x00000000000000000000)
st2            0	(raw 0x00000000000000000000)
st3            0	(raw 0x00000000000000000000)
st4            0	(raw 0x00000000000000000000)
st5            0	(raw 0x00000000000000000000)
st6            0	(raw 0x00000000000000000000)
st7            0	(raw 0x00000000000000000000)
fctrl          0x37f	895
fstat          0x6069	24681
ftag           0x13f	319
fiseg          0x73	115
fioff          0x8048bfd	134515709
foseg          0x7b	123
fooff          0x0	0
fop            0x2e9	745
xmm0           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm1           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
---Type <return> to continue, or q <return> to quit---
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm2           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm3           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm4           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm5           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm6           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
xmm7           {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0,
0x0}, v16_int8 = {0x0 <repeats 16 times>}, v8_int16 = {0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0}, v4_int32 = {0x0, 0x0, 0x0, 0x0},
v2_int64 = {0x0, 0x0}, uint128 = 0x00000000000000000000000000000000}
mxcsr          0x1f80	[ IM DM ZM OM UM PM ]
mm0            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm1            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm2            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm3            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm4            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm5            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm6            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
mm7            {uint64 = 0x0, v2_int32 = {0x0, 0x0}, v4_int16 = {0x0,
0x0, 0x0, 0x0}, v8_int8 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}
(gdb)


On Tue, Aug 4, 2009 at 22:25, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi Hui,
>
> tested following line.
> line 54:
> result = fmodf(no2,no1);
>
> please see the log below. all registers are same.
>
> ******************************************************************
> (gdb) n
> 52        printf("result is %f\n",result);
> (gdb) n
> result is 369.438751
> 54        result = fmodf(no2,no1);
> (gdb) info all-registers
> st0            0        (raw 0x00000000000000000000)
> st1            0        (raw 0x00000000000000000000)
> st2            0        (raw 0x00000000000000000000)
> st3            0        (raw 0x00000000000000000000)
> st4            0        (raw 0x00000000000000000000)
> st5            0        (raw 0x00000000000000000000)
> st6            88.87999725341796875     (raw 0x4005b1c28f0000000000)
> st7            369.438751220703125      (raw 0x4007b8b8290000000000)
> fctrl          0x37f    895
> fstat          0x20     32
> ftag           0xffff   65535
> fiseg          0x73     115
> fioff          0xb7eccd27       -1209217753
> foseg          0x7b     123
> fooff          0xbfffc0d4       -1073757996
> fop            0x0      0
> (gdb) n
> 55        printf("result is %f\n",result);
> (gdb)
> result is 10.320001
> 57        resultd = fmod(x,y);
> (gdb) reverse-next
> 55        printf("result is %f\n",result);
> (gdb)
> 54        result = fmodf(no2,no1);
> (gdb)
> 52        printf("result is %f\n",result);
> (gdb) info all-registers
> st0            0        (raw 0x00000000000000000000)
> st1            0        (raw 0x00000000000000000000)
> st2            0        (raw 0x00000000000000000000)
> st3            0        (raw 0x00000000000000000000)
> st4            0        (raw 0x00000000000000000000)
> st5            0        (raw 0x00000000000000000000)
> st6            88.87999725341796875     (raw 0x4005b1c28f0000000000)
> st7            369.43873691558837890625 (raw 0x4007b8b8288800000000)
> fctrl          0x37f    895
> fstat          0x20     32
> ftag           0xffff   65535
> fiseg          0x73     115
> fioff          0xb7eccd27       -1209217753
> foseg          0x7b     123
> fooff          0xbfffc0d4       -1073757996
> fop            0x0      0
> (gdb)
> ******************************************************************
>
> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Tuesday, August 4, 2009, 7:28 PM
>> I think you can do it with youself.
>>
>> Hui
>>
>> On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >
>> > Hi,
>> >
>> > As I understand you have tried to run the example test
>> code which I had sent earlier.
>> >
>> > please let me know at which c statement (or insn) it
>> is causing this ?
>> > So I can dig into it more.
>> >
>> > Thanks & Regards,
>> > Oza.
>> >
>> >
>> > --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com>
>> wrote:
>> >
>> >> From: paawan oza <paawan1982@yahoo.com>
>> >> Subject: Re: final i386.floating.record.patch
>> >> To: "Hui Zhu" <teawater@gmail.com>
>> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
>> "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>
>> >> Date: Tuesday, August 4, 2009, 6:32 PM
>> >> Hi Hui,
>> >> I am not sure which test case (insn)  caused
>> this.
>> >> would you please send me the example (.c file)
>> which you
>> >> have tried to run ?
>> >> please also try to let me know at which insn (at
>> which
>> >> point it fails).
>> >> Regards,
>> >> Oza.
>> >>
>> >> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
>> >> wrote:
>> >>
>> >> > From: Hui Zhu <teawater@gmail.com>
>> >> > Subject: Re: final
>> i386.floating.record.patch
>> >> > To: "paawan oza" <paawan1982@yahoo.com>
>> >> > Cc: "Michael Snyder" <msnyder@vmware.com>,
>> >> "gdb-patches@sourceware.org"
>> >> <gdb-patches@sourceware.org>
>> >> > Date: Tuesday, August 4, 2009, 8:49 AM
>> >> > Hi Paawan,
>> >> >
>> >> > Thanks for your work.
>> >> >
>> >> > I do a some test works with the test code
>> that you
>> >> sent in
>> >> > before.
>> >> > I get the values of fp reg with command
>> "info
>> >> > all-registers".
>> >> >
>> >> > It looks like some fp reg's values not right
>> in
>> >> replay
>> >> > mode.
>> >> >
>> >> > In record mode they are:
>> >> > fctrl
>> >> > 0x37f    895
>> >> > fstat
>> >> > 0x0    0
>> >> > ftag
>> >> >    0xffff    65535
>> >> > fiseg
>> >> > 0x0    0
>> >> > fioff
>> >> > 0x0    0
>> >> > ---Type <return> to continue, or q
>> >> <return> to
>> >> > quit---
>> >> > foseg
>> >> > 0x0    0
>> >> > fooff
>> >> > 0x0    0
>> >> > fop
>> >> > 0x0    0
>> >> >
>> >> > In replay mode they are:
>> >> > fctrl
>> >> > 0x37f    895
>> >> > fstat
>> >> > 0x6069    24681
>> >> > ftag
>> >> >    0x557f    21887
>> >> > fiseg
>> >> > 0x73    115
>> >> > fioff
>> >> > 0x8048bfd    134515709
>> >> > ---Type <return> to continue, or q
>> >> <return> to
>> >> > quit---
>> >> > foseg
>> >> > 0x7b    123
>> >> > fooff
>> >> > 0x0    0
>> >> > fop
>> >> > 0x2e9    745
>> >> >
>> >> >
>> >> >
>> >> > Thanks,
>> >> > Hui
>> >> >
>> >> >
>> >> > #include <stdio.h>
>> >> > #include <math.h>
>> >> > #include <stdlib.h>
>> >> >
>> >> > /* the test intends to test following insns.
>> >> > flds faddp fstps fstpl fldl fxch fabs fdivrp
>> fmulp
>> >> fsubrp
>> >> > fucomp fnstsw fsqrt
>> >> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp
>> fld1
>> >> fldl2t
>> >> > fldl2e FLDPI
>> >> > FLDLG2 FLDLN2
>> >> > FLDZ fincstp ffree fptan fpatan fincstp
>> fsincos
>> >> frndint
>> >> > fscale fsin fcos fcmovb
>> >> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave
>> frstor
>> >> fstsw
>> >> > */
>> >> >
>> >> > float no1,no2,no3,no4,no5,no6,no7;
>> >> > double x = 100.345, y = 25.7789;
>> >> > long double ldx = 88888888888888888888.88,
>> ldy =
>> >> > 9999999999999999999.99;
>> >> > float result,resultd,resultld;
>> >> > float *float_memory;
>> >> >
>> >> > /* initialization of floats */
>> >> > void init_floats()
>> >> > {
>> >> >  no1 = 10.45;
>> >> >  no2 = 20.77;
>> >> >  no3 = 156.89874646;
>> >> >  no4 = 14.56;
>> >> >  no5 = 11.11;
>> >> >  no6 = 66.77;
>> >> >  no7 = 88.88;
>> >> >  float_memory = malloc(sizeof(float) * 4);
>> >> >  *float_memory = 256.256;
>> >> >  *(float_memory + 1) = 356.356;
>> >> >  *(float_memory + 2) = 456.456;
>> >> >  *(float_memory + 3) = 556.556;
>> >> > }
>> >> >
>> >> > /* marks FPU stack as empty */
>> >> > void empty_fpu_stack()
>> >> > {
>> >> >  asm ("ffree %st(1) \n\t"
>> >> >       "ffree %st(2) \n\t"
>> >> >       "ffree %st(3) \n\t"
>> >> >       "ffree %st(4) \n\t"
>> >> >       "ffree %st(5) \n\t"
>> >> >       "ffree %st(6) \n\t"
>> >> >       "ffree %st(7)");
>> >> > }
>> >> >
>> >> > /* tests floating point arithmatic */
>> >> > void test_arith_floats()
>> >> > {
>> >> >  result = no1 + no2 + no3 + no4 + no5 + no6
>> +
>> >> no7;
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = fmodf(no2,no1);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  resultd = fmod(x,y);
>> >> >  printf("result is %f\n",resultd);
>> >> >
>> >> >  resultld = fmodl(ldy,ldy);
>> >> >  printf("result is %f\n",resultld);
>> >> >
>> >> >  result = fabsf(no1);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = no3 / no4;
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = no1 * no2 * no3 * no4;
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = no1 - no2 - no3 - no4;
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fchs");
>> >> >
>> >> >  /* test for f2xm1 */
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("f2xm1");
>> >> >
>> >> >  asm ("fyl2x");
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fxtract");
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fprem1");
>> >> >
>> >> >  /* decrement fpu stack pointer only status
>> >> register should
>> >> > get affected */
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >
>> >> >  empty_fpu_stack();
>> >> >
>> >> >  asm ("fld1");
>> >> >  asm ("fldl2t");
>> >> >  asm ("fldl2e");
>> >> >  asm ("fldpi");
>> >> >  asm ("fldlg2");
>> >> >  asm ("fldln2");
>> >> >  asm ("fldz");
>> >> >
>> >> >  empty_fpu_stack();
>> >> >  /* finishing emptying the stack */
>> >> >
>> >> >  result = sqrt(no3);
>> >> >  printf("result is %f\n",result);
>> >> > }
>> >> >
>> >> > void test_log_exp_floats()
>> >> > {
>> >> >  result = log10(no3);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = log(no3);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = exp10(no3);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = exp(no3);
>> >> >  printf("result is %f\n",result);
>> >> > }
>> >> >
>> >> > void test_trigo_floats()
>> >> > {
>> >> >  result = sin(30);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = cos(30);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = tan(30);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  result = atan(30);
>> >> >  printf("result is %f\n",result);
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fptan");
>> >> >
>> >> >  /* changes st1 and popping register stack
>> */
>> >> >  asm ("fpatan");
>> >> >
>> >> >  asm("fincstp");
>> >> >  asm ("fld %0" : :"m"(float_memory));
>> >> >  asm ("fsincos");
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("frndint");
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >> >  asm ("fscale");
>> >> >
>> >> >  empty_fpu_stack();
>> >> >
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fsin");
>> >> >  asm ("fcos");
>> >> >
>> >> >  /* currently we assume condition likely
>> and
>> >> always record
>> >> > the registers
>> >> >  code could be optimized only if the flag is
>> set
>> >> then
>> >> > record */
>> >> >  asm ("fld %0" : :"m"(*float_memory));
>> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >> >  asm ("fcmovb %st(1), %st");
>> >> >  asm ("fcmovbe %st(1), %st");
>> >> >  asm ("fcmove %st(1), %st");
>> >> >  asm ("fcmovu %st(1), %st");
>> >> >  asm ("fcmovnb %st(1), %st");
>> >> >  asm ("fcmovnbe %st(1), %st");
>> >> >
>> >> >  empty_fpu_stack();
>> >> >  /* finished emtyping the stack */
>> >> > }
>> >> >
>> >> > void test_compare_floats()
>> >> > {
>> >> >    ldy = 88888888888888888888.88;
>> >> >    if (ldx == ldy)
>> >> >      ldy =
>> >> > 7777777777777777777777777777.777;
>> >> >    else
>> >> >      ldy =
>> >> > 666666666666666666666666666.666;
>> >> > }
>> >> >
>> >> > /* test loading and saving of FPU environment
>> */
>> >> > void test_fpu_env()
>> >> > {
>> >> >  asm ("fsave %0" : "=m"(*float_memory) : );
>> >> >  asm ("frstor %0" : : "m"(*float_memory));
>> >> >  asm ("fstsw %ax");
>> >> > }
>> >> >
>> >> > int main()
>> >> > {
>> >> >    init_floats();
>> >> >    test_arith_floats();
>> >> >    test_log_exp_floats();
>> >> >    test_trigo_floats();
>> >> >    test_compare_floats();
>> >> >    test_fpu_env();
>> >> > }
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Mon, Aug 3, 2009 at 22:56, paawan
>> oza<paawan1982@yahoo.com>
>> >> > wrote:
>> >> > > Hi,
>> >> > >
>> >> > > please find the patch attached. I have
>> attached
>> >> as per
>> >> > your suggestion.
>> >> > > I am attaching it from opera browser.
>> >> > >
>> >> > > Regards,
>> >> > > Oza.
>> >> > >
>> >> > > --- On Thu, 7/30/09, Michael Snyder
>> <msnyder@vmware.com>
>> >> > wrote:
>> >> > >
>> >> > >> From: Michael Snyder <msnyder@vmware.com>
>> >> > >> Subject: Re: final
>> >> i386.floating.record.patch
>> >> > >> To: "paawan oza" <paawan1982@yahoo.com>
>> >> > >> Cc: "gdb-patches@sourceware.org"
>> >> > <gdb-patches@sourceware.org>
>> >> > >> Date: Thursday, July 30, 2009, 11:31
>> PM
>> >> > >> paawan oza wrote:
>> >> > >> > Hi,
>> >> > >> >
>> >> > >> > please find my answers below.
>> >> > >> >
>> >> > >> >  1) Are you using a Windows
>> machine to
>> >> send
>> >> > your
>> >> > >> >  emails?  If so,
>> >> > >> >  is it possible that there is
>> a
>> >> Unix/Linux
>> >> > >> machine you could
>> >> > >> >  try
>> >> > >> >  sending from?  Your
>> attachments look
>> >> OK
>> >> > for
>> >> > >> me, but
>> >> > >> >  some people
>> >> > >> >  seem to have had problems
>> with them.
>> >> > >> >
>> >> > >> > Oza : I used to send all from
>> windows
>> >> till
>> >> > now.
>> >> > >> > but this patch I sent it from
>> >> Linux...from
>> >> > opera.
>> >> > >> >   2) And are you using
>> cut-and-paste
>> >> to
>> >> > >> insert the patches
>> >> > >> >  into the
>> >> > >> >  body of your email?  That
>> would
>> >> certainly
>> >> > >> cause
>> >> > >> >  problems, because
>> >> > >> >  tabs might be changed into
>> spaces
>> >> (which
>> >> > is
>> >> > >> exactly what
>> >> > >> >  was
>> >> > >> >  causing patch to fail for me
>> today).
>> >> > >> >  Oza: yes I am using
>> copy-paste....I
>> >> dont
>> >> > know
>> >> > >> any-other way.
>> >> > >> > because attachmenet are not
>> welcome, so
>> >> I am
>> >> > not sure
>> >> > >> how I could proceed with this.
>> >> > >>
>> >> > >> It's not that attachments are not
>> welcome.
>> >> > >> There are various binary encodings
>> for
>> >> > attachments, and
>> >> > >> some of those binary encodings are
>> not
>> >> welcome.
>> >> > I
>> >> > >> think
>> >> > >> because there's no open-source way
>> of
>> >> decoding
>> >> > them.
>> >> > >>
>> >> > >> If you look at the list, you'll see
>> that
>> >> > attachments are
>> >> > >> used a lot.
>> >> > >>
>> >> > >> Copy-and-paste, though, in general
>> will not
>> >> work,
>> >> > because
>> >> > >> it
>> >> > >> usually changes tabs into spaces,
>> which ruins
>> >> a
>> >> > patch.
>> >> > >>
>> >> > >>
>> >> > >> > I will send you updated
>> patch.....may be
>> >> I
>> >> > might have
>> >> > >> mistaken of old gdb file. sorry for
>> >> incovenience.
>> >> > >>
>> >> > >> I think it was just the
>> tabs-to-spaces
>> >> issue.
>> >> > >> Why don't you try sending an
>> attachment from
>> >> > Opera?
>> >> > >>
>> >> > >>
>> >> > >
>> >> > >
>> >> > >
>> >> >
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> >
>>
>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 13:58 ` Hui Zhu
  2009-08-04 14:18   ` paawan oza
@ 2009-08-04 14:26   ` paawan oza
  2009-08-04 14:43     ` Hui Zhu
  1 sibling, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-08-04 14:26 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches


Hi Hui,

tested following line.
line 54:
result = fmodf(no2,no1);  

please see the log below. all registers are same.

******************************************************************
(gdb) n
52        printf("result is %f\n",result);
(gdb) n
result is 369.438751
54        result = fmodf(no2,no1);
(gdb) info all-registers
st0            0        (raw 0x00000000000000000000)
st1            0        (raw 0x00000000000000000000)
st2            0        (raw 0x00000000000000000000)
st3            0        (raw 0x00000000000000000000)
st4            0        (raw 0x00000000000000000000)
st5            0        (raw 0x00000000000000000000)
st6            88.87999725341796875     (raw 0x4005b1c28f0000000000)
st7            369.438751220703125      (raw 0x4007b8b8290000000000)
fctrl          0x37f    895
fstat          0x20     32
ftag           0xffff   65535
fiseg          0x73     115
fioff          0xb7eccd27       -1209217753
foseg          0x7b     123
fooff          0xbfffc0d4       -1073757996
fop            0x0      0
(gdb) n
55        printf("result is %f\n",result);
(gdb)
result is 10.320001
57        resultd = fmod(x,y);
(gdb) reverse-next
55        printf("result is %f\n",result);
(gdb)
54        result = fmodf(no2,no1);
(gdb)
52        printf("result is %f\n",result);
(gdb) info all-registers
st0            0        (raw 0x00000000000000000000)
st1            0        (raw 0x00000000000000000000)
st2            0        (raw 0x00000000000000000000)
st3            0        (raw 0x00000000000000000000)
st4            0        (raw 0x00000000000000000000)
st5            0        (raw 0x00000000000000000000)
st6            88.87999725341796875     (raw 0x4005b1c28f0000000000)
st7            369.43873691558837890625 (raw 0x4007b8b8288800000000)
fctrl          0x37f    895
fstat          0x20     32
ftag           0xffff   65535
fiseg          0x73     115
fioff          0xb7eccd27       -1209217753
foseg          0x7b     123
fooff          0xbfffc0d4       -1073757996
fop            0x0      0
(gdb)
******************************************************************

--- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, August 4, 2009, 7:28 PM
> I think you can do it with youself.
> 
> Hui
> 
> On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> >
> > As I understand you have tried to run the example test
> code which I had sent earlier.
> >
> > please let me know at which c statement (or insn) it
> is causing this ?
> > So I can dig into it more.
> >
> > Thanks & Regards,
> > Oza.
> >
> >
> > --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com>
> wrote:
> >
> >> From: paawan oza <paawan1982@yahoo.com>
> >> Subject: Re: final i386.floating.record.patch
> >> To: "Hui Zhu" <teawater@gmail.com>
> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Tuesday, August 4, 2009, 6:32 PM
> >> Hi Hui,
> >> I am not sure which test case (insn)  caused
> this.
> >> would you please send me the example (.c file)
> which you
> >> have tried to run ?
> >> please also try to let me know at which insn (at
> which
> >> point it fails).
> >> Regards,
> >> Oza.
> >>
> >> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
> >> wrote:
> >>
> >> > From: Hui Zhu <teawater@gmail.com>
> >> > Subject: Re: final
> i386.floating.record.patch
> >> > To: "paawan oza" <paawan1982@yahoo.com>
> >> > Cc: "Michael Snyder" <msnyder@vmware.com>,
> >> "gdb-patches@sourceware.org"
> >> <gdb-patches@sourceware.org>
> >> > Date: Tuesday, August 4, 2009, 8:49 AM
> >> > Hi Paawan,
> >> >
> >> > Thanks for your work.
> >> >
> >> > I do a some test works with the test code
> that you
> >> sent in
> >> > before.
> >> > I get the values of fp reg with command
> "info
> >> > all-registers".
> >> >
> >> > It looks like some fp reg's values not right
> in
> >> replay
> >> > mode.
> >> >
> >> > In record mode they are:
> >> > fctrl
> >> > 0x37f    895
> >> > fstat
> >> > 0x0    0
> >> > ftag
> >> >    0xffff    65535
> >> > fiseg
> >> > 0x0    0
> >> > fioff
> >> > 0x0    0
> >> > ---Type <return> to continue, or q
> >> <return> to
> >> > quit---
> >> > foseg
> >> > 0x0    0
> >> > fooff
> >> > 0x0    0
> >> > fop
> >> > 0x0    0
> >> >
> >> > In replay mode they are:
> >> > fctrl
> >> > 0x37f    895
> >> > fstat
> >> > 0x6069    24681
> >> > ftag
> >> >    0x557f    21887
> >> > fiseg
> >> > 0x73    115
> >> > fioff
> >> > 0x8048bfd    134515709
> >> > ---Type <return> to continue, or q
> >> <return> to
> >> > quit---
> >> > foseg
> >> > 0x7b    123
> >> > fooff
> >> > 0x0    0
> >> > fop
> >> > 0x2e9    745
> >> >
> >> >
> >> >
> >> > Thanks,
> >> > Hui
> >> >
> >> >
> >> > #include <stdio.h>
> >> > #include <math.h>
> >> > #include <stdlib.h>
> >> >
> >> > /* the test intends to test following insns.
> >> > flds faddp fstps fstpl fldl fxch fabs fdivrp
> fmulp
> >> fsubrp
> >> > fucomp fnstsw fsqrt
> >> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp
> fld1
> >> fldl2t
> >> > fldl2e FLDPI
> >> > FLDLG2 FLDLN2
> >> > FLDZ fincstp ffree fptan fpatan fincstp
> fsincos
> >> frndint
> >> > fscale fsin fcos fcmovb
> >> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave
> frstor
> >> fstsw
> >> > */
> >> >
> >> > float no1,no2,no3,no4,no5,no6,no7;
> >> > double x = 100.345, y = 25.7789;
> >> > long double ldx = 88888888888888888888.88,
> ldy =
> >> > 9999999999999999999.99;
> >> > float result,resultd,resultld;
> >> > float *float_memory;
> >> >
> >> > /* initialization of floats */
> >> > void init_floats()
> >> > {
> >> >  no1 = 10.45;
> >> >  no2 = 20.77;
> >> >  no3 = 156.89874646;
> >> >  no4 = 14.56;
> >> >  no5 = 11.11;
> >> >  no6 = 66.77;
> >> >  no7 = 88.88;
> >> >  float_memory = malloc(sizeof(float) * 4);
> >> >  *float_memory = 256.256;
> >> >  *(float_memory + 1) = 356.356;
> >> >  *(float_memory + 2) = 456.456;
> >> >  *(float_memory + 3) = 556.556;
> >> > }
> >> >
> >> > /* marks FPU stack as empty */
> >> > void empty_fpu_stack()
> >> > {
> >> >  asm ("ffree %st(1) \n\t"
> >> >       "ffree %st(2) \n\t"
> >> >       "ffree %st(3) \n\t"
> >> >       "ffree %st(4) \n\t"
> >> >       "ffree %st(5) \n\t"
> >> >       "ffree %st(6) \n\t"
> >> >       "ffree %st(7)");
> >> > }
> >> >
> >> > /* tests floating point arithmatic */
> >> > void test_arith_floats()
> >> > {
> >> >  result = no1 + no2 + no3 + no4 + no5 + no6
> +
> >> no7;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = fmodf(no2,no1);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  resultd = fmod(x,y);
> >> >  printf("result is %f\n",resultd);
> >> >
> >> >  resultld = fmodl(ldy,ldy);
> >> >  printf("result is %f\n",resultld);
> >> >
> >> >  result = fabsf(no1);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no3 / no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no1 * no2 * no3 * no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no1 - no2 - no3 - no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fchs");
> >> >
> >> >  /* test for f2xm1 */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("f2xm1");
> >> >
> >> >  asm ("fyl2x");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fxtract");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fprem1");
> >> >
> >> >  /* decrement fpu stack pointer only status
> >> register should
> >> > get affected */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >
> >> >  empty_fpu_stack();
> >> >
> >> >  asm ("fld1");
> >> >  asm ("fldl2t");
> >> >  asm ("fldl2e");
> >> >  asm ("fldpi");
> >> >  asm ("fldlg2");
> >> >  asm ("fldln2");
> >> >  asm ("fldz");
> >> >
> >> >  empty_fpu_stack();
> >> >  /* finishing emptying the stack */
> >> >
> >> >  result = sqrt(no3);
> >> >  printf("result is %f\n",result);
> >> > }
> >> >
> >> > void test_log_exp_floats()
> >> > {
> >> >  result = log10(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = log(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = exp10(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = exp(no3);
> >> >  printf("result is %f\n",result);
> >> > }
> >> >
> >> > void test_trigo_floats()
> >> > {
> >> >  result = sin(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = cos(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = tan(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = atan(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fptan");
> >> >
> >> >  /* changes st1 and popping register stack
> */
> >> >  asm ("fpatan");
> >> >
> >> >  asm("fincstp");
> >> >  asm ("fld %0" : :"m"(float_memory));
> >> >  asm ("fsincos");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("frndint");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >> >  asm ("fscale");
> >> >
> >> >  empty_fpu_stack();
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fsin");
> >> >  asm ("fcos");
> >> >
> >> >  /* currently we assume condition likely
> and
> >> always record
> >> > the registers
> >> >  code could be optimized only if the flag is
> set
> >> then
> >> > record */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >> >  asm ("fcmovb %st(1), %st");
> >> >  asm ("fcmovbe %st(1), %st");
> >> >  asm ("fcmove %st(1), %st");
> >> >  asm ("fcmovu %st(1), %st");
> >> >  asm ("fcmovnb %st(1), %st");
> >> >  asm ("fcmovnbe %st(1), %st");
> >> >
> >> >  empty_fpu_stack();
> >> >  /* finished emtyping the stack */
> >> > }
> >> >
> >> > void test_compare_floats()
> >> > {
> >> >    ldy = 88888888888888888888.88;
> >> >    if (ldx == ldy)
> >> >      ldy =
> >> > 7777777777777777777777777777.777;
> >> >    else
> >> >      ldy =
> >> > 666666666666666666666666666.666;
> >> > }
> >> >
> >> > /* test loading and saving of FPU environment
> */
> >> > void test_fpu_env()
> >> > {
> >> >  asm ("fsave %0" : "=m"(*float_memory) : );
> >> >  asm ("frstor %0" : : "m"(*float_memory));
> >> >  asm ("fstsw %ax");
> >> > }
> >> >
> >> > int main()
> >> > {
> >> >    init_floats();
> >> >    test_arith_floats();
> >> >    test_log_exp_floats();
> >> >    test_trigo_floats();
> >> >    test_compare_floats();
> >> >    test_fpu_env();
> >> > }
> >> >
> >> >
> >> >
> >> >
> >> > On Mon, Aug 3, 2009 at 22:56, paawan
> oza<paawan1982@yahoo.com>
> >> > wrote:
> >> > > Hi,
> >> > >
> >> > > please find the patch attached. I have
> attached
> >> as per
> >> > your suggestion.
> >> > > I am attaching it from opera browser.
> >> > >
> >> > > Regards,
> >> > > Oza.
> >> > >
> >> > > --- On Thu, 7/30/09, Michael Snyder
> <msnyder@vmware.com>
> >> > wrote:
> >> > >
> >> > >> From: Michael Snyder <msnyder@vmware.com>
> >> > >> Subject: Re: final
> >> i386.floating.record.patch
> >> > >> To: "paawan oza" <paawan1982@yahoo.com>
> >> > >> Cc: "gdb-patches@sourceware.org"
> >> > <gdb-patches@sourceware.org>
> >> > >> Date: Thursday, July 30, 2009, 11:31
> PM
> >> > >> paawan oza wrote:
> >> > >> > Hi,
> >> > >> >
> >> > >> > please find my answers below.
> >> > >> >
> >> > >> >  1) Are you using a Windows
> machine to
> >> send
> >> > your
> >> > >> >  emails?  If so,
> >> > >> >  is it possible that there is
> a
> >> Unix/Linux
> >> > >> machine you could
> >> > >> >  try
> >> > >> >  sending from?  Your
> attachments look
> >> OK
> >> > for
> >> > >> me, but
> >> > >> >  some people
> >> > >> >  seem to have had problems
> with them.
> >> > >> >
> >> > >> > Oza : I used to send all from
> windows
> >> till
> >> > now.
> >> > >> > but this patch I sent it from
> >> Linux...from
> >> > opera.
> >> > >> >   2) And are you using
> cut-and-paste
> >> to
> >> > >> insert the patches
> >> > >> >  into the
> >> > >> >  body of your email?  That
> would
> >> certainly
> >> > >> cause
> >> > >> >  problems, because
> >> > >> >  tabs might be changed into
> spaces
> >> (which
> >> > is
> >> > >> exactly what
> >> > >> >  was
> >> > >> >  causing patch to fail for me
> today).
> >> > >> >  Oza: yes I am using
> copy-paste....I
> >> dont
> >> > know
> >> > >> any-other way.
> >> > >> > because attachmenet are not
> welcome, so
> >> I am
> >> > not sure
> >> > >> how I could proceed with this.
> >> > >>
> >> > >> It's not that attachments are not
> welcome.
> >> > >> There are various binary encodings
> for
> >> > attachments, and
> >> > >> some of those binary encodings are
> not
> >> welcome.
> >> > I
> >> > >> think
> >> > >> because there's no open-source way
> of
> >> decoding
> >> > them.
> >> > >>
> >> > >> If you look at the list, you'll see
> that
> >> > attachments are
> >> > >> used a lot.
> >> > >>
> >> > >> Copy-and-paste, though, in general
> will not
> >> work,
> >> > because
> >> > >> it
> >> > >> usually changes tabs into spaces,
> which ruins
> >> a
> >> > patch.
> >> > >>
> >> > >>
> >> > >> > I will send you updated
> patch.....may be
> >> I
> >> > might have
> >> > >> mistaken of old gdb file. sorry for
> >> incovenience.
> >> > >>
> >> > >> I think it was just the
> tabs-to-spaces
> >> issue.
> >> > >> Why don't you try sending an
> attachment from
> >> > Opera?
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> > >
> >> >
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 13:58 ` Hui Zhu
@ 2009-08-04 14:18   ` paawan oza
  2009-08-04 14:26   ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-08-04 14:18 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches


Hi Hui,

I am trying, but  am unable to reproduce it.
I am enabling the 'record' mode from begning....and trying 'reverse-next'.
It seems to be working.

please let me know if I need to do anything more to reproduce.

Regards,
Oza.



--- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com> wrote:

> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: final i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, August 4, 2009, 7:28 PM
> I think you can do it with youself.
> 
> Hui
> 
> On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> >
> > As I understand you have tried to run the example test
> code which I had sent earlier.
> >
> > please let me know at which c statement (or insn) it
> is causing this ?
> > So I can dig into it more.
> >
> > Thanks & Regards,
> > Oza.
> >
> >
> > --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com>
> wrote:
> >
> >> From: paawan oza <paawan1982@yahoo.com>
> >> Subject: Re: final i386.floating.record.patch
> >> To: "Hui Zhu" <teawater@gmail.com>
> >> Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Tuesday, August 4, 2009, 6:32 PM
> >> Hi Hui,
> >> I am not sure which test case (insn)  caused
> this.
> >> would you please send me the example (.c file)
> which you
> >> have tried to run ?
> >> please also try to let me know at which insn (at
> which
> >> point it fails).
> >> Regards,
> >> Oza.
> >>
> >> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
> >> wrote:
> >>
> >> > From: Hui Zhu <teawater@gmail.com>
> >> > Subject: Re: final
> i386.floating.record.patch
> >> > To: "paawan oza" <paawan1982@yahoo.com>
> >> > Cc: "Michael Snyder" <msnyder@vmware.com>,
> >> "gdb-patches@sourceware.org"
> >> <gdb-patches@sourceware.org>
> >> > Date: Tuesday, August 4, 2009, 8:49 AM
> >> > Hi Paawan,
> >> >
> >> > Thanks for your work.
> >> >
> >> > I do a some test works with the test code
> that you
> >> sent in
> >> > before.
> >> > I get the values of fp reg with command
> "info
> >> > all-registers".
> >> >
> >> > It looks like some fp reg's values not right
> in
> >> replay
> >> > mode.
> >> >
> >> > In record mode they are:
> >> > fctrl
> >> > 0x37f    895
> >> > fstat
> >> > 0x0    0
> >> > ftag
> >> >    0xffff    65535
> >> > fiseg
> >> > 0x0    0
> >> > fioff
> >> > 0x0    0
> >> > ---Type <return> to continue, or q
> >> <return> to
> >> > quit---
> >> > foseg
> >> > 0x0    0
> >> > fooff
> >> > 0x0    0
> >> > fop
> >> > 0x0    0
> >> >
> >> > In replay mode they are:
> >> > fctrl
> >> > 0x37f    895
> >> > fstat
> >> > 0x6069    24681
> >> > ftag
> >> >    0x557f    21887
> >> > fiseg
> >> > 0x73    115
> >> > fioff
> >> > 0x8048bfd    134515709
> >> > ---Type <return> to continue, or q
> >> <return> to
> >> > quit---
> >> > foseg
> >> > 0x7b    123
> >> > fooff
> >> > 0x0    0
> >> > fop
> >> > 0x2e9    745
> >> >
> >> >
> >> >
> >> > Thanks,
> >> > Hui
> >> >
> >> >
> >> > #include <stdio.h>
> >> > #include <math.h>
> >> > #include <stdlib.h>
> >> >
> >> > /* the test intends to test following insns.
> >> > flds faddp fstps fstpl fldl fxch fabs fdivrp
> fmulp
> >> fsubrp
> >> > fucomp fnstsw fsqrt
> >> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp
> fld1
> >> fldl2t
> >> > fldl2e FLDPI
> >> > FLDLG2 FLDLN2
> >> > FLDZ fincstp ffree fptan fpatan fincstp
> fsincos
> >> frndint
> >> > fscale fsin fcos fcmovb
> >> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave
> frstor
> >> fstsw
> >> > */
> >> >
> >> > float no1,no2,no3,no4,no5,no6,no7;
> >> > double x = 100.345, y = 25.7789;
> >> > long double ldx = 88888888888888888888.88,
> ldy =
> >> > 9999999999999999999.99;
> >> > float result,resultd,resultld;
> >> > float *float_memory;
> >> >
> >> > /* initialization of floats */
> >> > void init_floats()
> >> > {
> >> >  no1 = 10.45;
> >> >  no2 = 20.77;
> >> >  no3 = 156.89874646;
> >> >  no4 = 14.56;
> >> >  no5 = 11.11;
> >> >  no6 = 66.77;
> >> >  no7 = 88.88;
> >> >  float_memory = malloc(sizeof(float) * 4);
> >> >  *float_memory = 256.256;
> >> >  *(float_memory + 1) = 356.356;
> >> >  *(float_memory + 2) = 456.456;
> >> >  *(float_memory + 3) = 556.556;
> >> > }
> >> >
> >> > /* marks FPU stack as empty */
> >> > void empty_fpu_stack()
> >> > {
> >> >  asm ("ffree %st(1) \n\t"
> >> >       "ffree %st(2) \n\t"
> >> >       "ffree %st(3) \n\t"
> >> >       "ffree %st(4) \n\t"
> >> >       "ffree %st(5) \n\t"
> >> >       "ffree %st(6) \n\t"
> >> >       "ffree %st(7)");
> >> > }
> >> >
> >> > /* tests floating point arithmatic */
> >> > void test_arith_floats()
> >> > {
> >> >  result = no1 + no2 + no3 + no4 + no5 + no6
> +
> >> no7;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = fmodf(no2,no1);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  resultd = fmod(x,y);
> >> >  printf("result is %f\n",resultd);
> >> >
> >> >  resultld = fmodl(ldy,ldy);
> >> >  printf("result is %f\n",resultld);
> >> >
> >> >  result = fabsf(no1);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no3 / no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no1 * no2 * no3 * no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = no1 - no2 - no3 - no4;
> >> >  printf("result is %f\n",result);
> >> >
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fchs");
> >> >
> >> >  /* test for f2xm1 */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("f2xm1");
> >> >
> >> >  asm ("fyl2x");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fxtract");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fprem1");
> >> >
> >> >  /* decrement fpu stack pointer only status
> >> register should
> >> > get affected */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >
> >> >  empty_fpu_stack();
> >> >
> >> >  asm ("fld1");
> >> >  asm ("fldl2t");
> >> >  asm ("fldl2e");
> >> >  asm ("fldpi");
> >> >  asm ("fldlg2");
> >> >  asm ("fldln2");
> >> >  asm ("fldz");
> >> >
> >> >  empty_fpu_stack();
> >> >  /* finishing emptying the stack */
> >> >
> >> >  result = sqrt(no3);
> >> >  printf("result is %f\n",result);
> >> > }
> >> >
> >> > void test_log_exp_floats()
> >> > {
> >> >  result = log10(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = log(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = exp10(no3);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = exp(no3);
> >> >  printf("result is %f\n",result);
> >> > }
> >> >
> >> > void test_trigo_floats()
> >> > {
> >> >  result = sin(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = cos(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = tan(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  result = atan(30);
> >> >  printf("result is %f\n",result);
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fptan");
> >> >
> >> >  /* changes st1 and popping register stack
> */
> >> >  asm ("fpatan");
> >> >
> >> >  asm("fincstp");
> >> >  asm ("fld %0" : :"m"(float_memory));
> >> >  asm ("fsincos");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("frndint");
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >> >  asm ("fscale");
> >> >
> >> >  empty_fpu_stack();
> >> >
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fsin");
> >> >  asm ("fcos");
> >> >
> >> >  /* currently we assume condition likely
> and
> >> always record
> >> > the registers
> >> >  code could be optimized only if the flag is
> set
> >> then
> >> > record */
> >> >  asm ("fld %0" : :"m"(*float_memory));
> >> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >> >  asm ("fcmovb %st(1), %st");
> >> >  asm ("fcmovbe %st(1), %st");
> >> >  asm ("fcmove %st(1), %st");
> >> >  asm ("fcmovu %st(1), %st");
> >> >  asm ("fcmovnb %st(1), %st");
> >> >  asm ("fcmovnbe %st(1), %st");
> >> >
> >> >  empty_fpu_stack();
> >> >  /* finished emtyping the stack */
> >> > }
> >> >
> >> > void test_compare_floats()
> >> > {
> >> >    ldy = 88888888888888888888.88;
> >> >    if (ldx == ldy)
> >> >      ldy =
> >> > 7777777777777777777777777777.777;
> >> >    else
> >> >      ldy =
> >> > 666666666666666666666666666.666;
> >> > }
> >> >
> >> > /* test loading and saving of FPU environment
> */
> >> > void test_fpu_env()
> >> > {
> >> >  asm ("fsave %0" : "=m"(*float_memory) : );
> >> >  asm ("frstor %0" : : "m"(*float_memory));
> >> >  asm ("fstsw %ax");
> >> > }
> >> >
> >> > int main()
> >> > {
> >> >    init_floats();
> >> >    test_arith_floats();
> >> >    test_log_exp_floats();
> >> >    test_trigo_floats();
> >> >    test_compare_floats();
> >> >    test_fpu_env();
> >> > }
> >> >
> >> >
> >> >
> >> >
> >> > On Mon, Aug 3, 2009 at 22:56, paawan
> oza<paawan1982@yahoo.com>
> >> > wrote:
> >> > > Hi,
> >> > >
> >> > > please find the patch attached. I have
> attached
> >> as per
> >> > your suggestion.
> >> > > I am attaching it from opera browser.
> >> > >
> >> > > Regards,
> >> > > Oza.
> >> > >
> >> > > --- On Thu, 7/30/09, Michael Snyder
> <msnyder@vmware.com>
> >> > wrote:
> >> > >
> >> > >> From: Michael Snyder <msnyder@vmware.com>
> >> > >> Subject: Re: final
> >> i386.floating.record.patch
> >> > >> To: "paawan oza" <paawan1982@yahoo.com>
> >> > >> Cc: "gdb-patches@sourceware.org"
> >> > <gdb-patches@sourceware.org>
> >> > >> Date: Thursday, July 30, 2009, 11:31
> PM
> >> > >> paawan oza wrote:
> >> > >> > Hi,
> >> > >> >
> >> > >> > please find my answers below.
> >> > >> >
> >> > >> >  1) Are you using a Windows
> machine to
> >> send
> >> > your
> >> > >> >  emails?  If so,
> >> > >> >  is it possible that there is
> a
> >> Unix/Linux
> >> > >> machine you could
> >> > >> >  try
> >> > >> >  sending from?  Your
> attachments look
> >> OK
> >> > for
> >> > >> me, but
> >> > >> >  some people
> >> > >> >  seem to have had problems
> with them.
> >> > >> >
> >> > >> > Oza : I used to send all from
> windows
> >> till
> >> > now.
> >> > >> > but this patch I sent it from
> >> Linux...from
> >> > opera.
> >> > >> >   2) And are you using
> cut-and-paste
> >> to
> >> > >> insert the patches
> >> > >> >  into the
> >> > >> >  body of your email?  That
> would
> >> certainly
> >> > >> cause
> >> > >> >  problems, because
> >> > >> >  tabs might be changed into
> spaces
> >> (which
> >> > is
> >> > >> exactly what
> >> > >> >  was
> >> > >> >  causing patch to fail for me
> today).
> >> > >> >  Oza: yes I am using
> copy-paste....I
> >> dont
> >> > know
> >> > >> any-other way.
> >> > >> > because attachmenet are not
> welcome, so
> >> I am
> >> > not sure
> >> > >> how I could proceed with this.
> >> > >>
> >> > >> It's not that attachments are not
> welcome.
> >> > >> There are various binary encodings
> for
> >> > attachments, and
> >> > >> some of those binary encodings are
> not
> >> welcome.
> >> > I
> >> > >> think
> >> > >> because there's no open-source way
> of
> >> decoding
> >> > them.
> >> > >>
> >> > >> If you look at the list, you'll see
> that
> >> > attachments are
> >> > >> used a lot.
> >> > >>
> >> > >> Copy-and-paste, though, in general
> will not
> >> work,
> >> > because
> >> > >> it
> >> > >> usually changes tabs into spaces,
> which ruins
> >> a
> >> > patch.
> >> > >>
> >> > >>
> >> > >> > I will send you updated
> patch.....may be
> >> I
> >> > might have
> >> > >> mistaken of old gdb file. sorry for
> >> incovenience.
> >> > >>
> >> > >> I think it was just the
> tabs-to-spaces
> >> issue.
> >> > >> Why don't you try sending an
> attachment from
> >> > Opera?
> >> > >>
> >> > >>
> >> > >
> >> > >
> >> > >
> >> >
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
  2009-08-04 13:06 paawan oza
@ 2009-08-04 13:58 ` Hui Zhu
  2009-08-04 14:18   ` paawan oza
  2009-08-04 14:26   ` paawan oza
  0 siblings, 2 replies; 40+ messages in thread
From: Hui Zhu @ 2009-08-04 13:58 UTC (permalink / raw)
  To: paawan oza; +Cc: Michael Snyder, gdb-patches

I think you can do it with youself.

Hui

On Tue, Aug 4, 2009 at 21:05, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi,
>
> As I understand you have tried to run the example test code which I had sent earlier.
>
> please let me know at which c statement (or insn) it is causing this ?
> So I can dig into it more.
>
> Thanks & Regards,
> Oza.
>
>
> --- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com> wrote:
>
>> From: paawan oza <paawan1982@yahoo.com>
>> Subject: Re: final i386.floating.record.patch
>> To: "Hui Zhu" <teawater@gmail.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Tuesday, August 4, 2009, 6:32 PM
>> Hi Hui,
>> I am not sure which test case (insn)  caused this.
>> would you please send me the example (.c file) which you
>> have tried to run ?
>> please also try to let me know at which insn (at which
>> point it fails).
>> Regards,
>> Oza.
>>
>> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
>> wrote:
>>
>> > From: Hui Zhu <teawater@gmail.com>
>> > Subject: Re: final i386.floating.record.patch
>> > To: "paawan oza" <paawan1982@yahoo.com>
>> > Cc: "Michael Snyder" <msnyder@vmware.com>,
>> "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>
>> > Date: Tuesday, August 4, 2009, 8:49 AM
>> > Hi Paawan,
>> >
>> > Thanks for your work.
>> >
>> > I do a some test works with the test code that you
>> sent in
>> > before.
>> > I get the values of fp reg with command "info
>> > all-registers".
>> >
>> > It looks like some fp reg's values not right in
>> replay
>> > mode.
>> >
>> > In record mode they are:
>> > fctrl
>> > 0x37f    895
>> > fstat
>> > 0x0    0
>> > ftag
>> >    0xffff    65535
>> > fiseg
>> > 0x0    0
>> > fioff
>> > 0x0    0
>> > ---Type <return> to continue, or q
>> <return> to
>> > quit---
>> > foseg
>> > 0x0    0
>> > fooff
>> > 0x0    0
>> > fop
>> > 0x0    0
>> >
>> > In replay mode they are:
>> > fctrl
>> > 0x37f    895
>> > fstat
>> > 0x6069    24681
>> > ftag
>> >    0x557f    21887
>> > fiseg
>> > 0x73    115
>> > fioff
>> > 0x8048bfd    134515709
>> > ---Type <return> to continue, or q
>> <return> to
>> > quit---
>> > foseg
>> > 0x7b    123
>> > fooff
>> > 0x0    0
>> > fop
>> > 0x2e9    745
>> >
>> >
>> >
>> > Thanks,
>> > Hui
>> >
>> >
>> > #include <stdio.h>
>> > #include <math.h>
>> > #include <stdlib.h>
>> >
>> > /* the test intends to test following insns.
>> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
>> fsubrp
>> > fucomp fnstsw fsqrt
>> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
>> fldl2t
>> > fldl2e FLDPI
>> > FLDLG2 FLDLN2
>> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
>> frndint
>> > fscale fsin fcos fcmovb
>> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
>> fstsw
>> > */
>> >
>> > float no1,no2,no3,no4,no5,no6,no7;
>> > double x = 100.345, y = 25.7789;
>> > long double ldx = 88888888888888888888.88, ldy =
>> > 9999999999999999999.99;
>> > float result,resultd,resultld;
>> > float *float_memory;
>> >
>> > /* initialization of floats */
>> > void init_floats()
>> > {
>> >  no1 = 10.45;
>> >  no2 = 20.77;
>> >  no3 = 156.89874646;
>> >  no4 = 14.56;
>> >  no5 = 11.11;
>> >  no6 = 66.77;
>> >  no7 = 88.88;
>> >  float_memory = malloc(sizeof(float) * 4);
>> >  *float_memory = 256.256;
>> >  *(float_memory + 1) = 356.356;
>> >  *(float_memory + 2) = 456.456;
>> >  *(float_memory + 3) = 556.556;
>> > }
>> >
>> > /* marks FPU stack as empty */
>> > void empty_fpu_stack()
>> > {
>> >  asm ("ffree %st(1) \n\t"
>> >       "ffree %st(2) \n\t"
>> >       "ffree %st(3) \n\t"
>> >       "ffree %st(4) \n\t"
>> >       "ffree %st(5) \n\t"
>> >       "ffree %st(6) \n\t"
>> >       "ffree %st(7)");
>> > }
>> >
>> > /* tests floating point arithmatic */
>> > void test_arith_floats()
>> > {
>> >  result = no1 + no2 + no3 + no4 + no5 + no6 +
>> no7;
>> >  printf("result is %f\n",result);
>> >
>> >  result = fmodf(no2,no1);
>> >  printf("result is %f\n",result);
>> >
>> >  resultd = fmod(x,y);
>> >  printf("result is %f\n",resultd);
>> >
>> >  resultld = fmodl(ldy,ldy);
>> >  printf("result is %f\n",resultld);
>> >
>> >  result = fabsf(no1);
>> >  printf("result is %f\n",result);
>> >
>> >  result = no3 / no4;
>> >  printf("result is %f\n",result);
>> >
>> >  result = no1 * no2 * no3 * no4;
>> >  printf("result is %f\n",result);
>> >
>> >  result = no1 - no2 - no3 - no4;
>> >  printf("result is %f\n",result);
>> >
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fchs");
>> >
>> >  /* test for f2xm1 */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("f2xm1");
>> >
>> >  asm ("fyl2x");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fxtract");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fprem1");
>> >
>> >  /* decrement fpu stack pointer only status
>> register should
>> > get affected */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >
>> >  empty_fpu_stack();
>> >
>> >  asm ("fld1");
>> >  asm ("fldl2t");
>> >  asm ("fldl2e");
>> >  asm ("fldpi");
>> >  asm ("fldlg2");
>> >  asm ("fldln2");
>> >  asm ("fldz");
>> >
>> >  empty_fpu_stack();
>> >  /* finishing emptying the stack */
>> >
>> >  result = sqrt(no3);
>> >  printf("result is %f\n",result);
>> > }
>> >
>> > void test_log_exp_floats()
>> > {
>> >  result = log10(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = log(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = exp10(no3);
>> >  printf("result is %f\n",result);
>> >
>> >  result = exp(no3);
>> >  printf("result is %f\n",result);
>> > }
>> >
>> > void test_trigo_floats()
>> > {
>> >  result = sin(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = cos(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = tan(30);
>> >  printf("result is %f\n",result);
>> >
>> >  result = atan(30);
>> >  printf("result is %f\n",result);
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fptan");
>> >
>> >  /* changes st1 and popping register stack */
>> >  asm ("fpatan");
>> >
>> >  asm("fincstp");
>> >  asm ("fld %0" : :"m"(float_memory));
>> >  asm ("fsincos");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("frndint");
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >  asm ("fscale");
>> >
>> >  empty_fpu_stack();
>> >
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fsin");
>> >  asm ("fcos");
>> >
>> >  /* currently we assume condition likely and
>> always record
>> > the registers
>> >  code could be optimized only if the flag is set
>> then
>> > record */
>> >  asm ("fld %0" : :"m"(*float_memory));
>> >  asm ("fld %0" : :"m"(*(float_memory+1)));
>> >  asm ("fcmovb %st(1), %st");
>> >  asm ("fcmovbe %st(1), %st");
>> >  asm ("fcmove %st(1), %st");
>> >  asm ("fcmovu %st(1), %st");
>> >  asm ("fcmovnb %st(1), %st");
>> >  asm ("fcmovnbe %st(1), %st");
>> >
>> >  empty_fpu_stack();
>> >  /* finished emtyping the stack */
>> > }
>> >
>> > void test_compare_floats()
>> > {
>> >    ldy = 88888888888888888888.88;
>> >    if (ldx == ldy)
>> >      ldy =
>> > 7777777777777777777777777777.777;
>> >    else
>> >      ldy =
>> > 666666666666666666666666666.666;
>> > }
>> >
>> > /* test loading and saving of FPU environment */
>> > void test_fpu_env()
>> > {
>> >  asm ("fsave %0" : "=m"(*float_memory) : );
>> >  asm ("frstor %0" : : "m"(*float_memory));
>> >  asm ("fstsw %ax");
>> > }
>> >
>> > int main()
>> > {
>> >    init_floats();
>> >    test_arith_floats();
>> >    test_log_exp_floats();
>> >    test_trigo_floats();
>> >    test_compare_floats();
>> >    test_fpu_env();
>> > }
>> >
>> >
>> >
>> >
>> > On Mon, Aug 3, 2009 at 22:56, paawan oza<paawan1982@yahoo.com>
>> > wrote:
>> > > Hi,
>> > >
>> > > please find the patch attached. I have attached
>> as per
>> > your suggestion.
>> > > I am attaching it from opera browser.
>> > >
>> > > Regards,
>> > > Oza.
>> > >
>> > > --- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com>
>> > wrote:
>> > >
>> > >> From: Michael Snyder <msnyder@vmware.com>
>> > >> Subject: Re: final
>> i386.floating.record.patch
>> > >> To: "paawan oza" <paawan1982@yahoo.com>
>> > >> Cc: "gdb-patches@sourceware.org"
>> > <gdb-patches@sourceware.org>
>> > >> Date: Thursday, July 30, 2009, 11:31 PM
>> > >> paawan oza wrote:
>> > >> > Hi,
>> > >> >
>> > >> > please find my answers below.
>> > >> >
>> > >> >  1) Are you using a Windows machine to
>> send
>> > your
>> > >> >  emails?  If so,
>> > >> >  is it possible that there is a
>> Unix/Linux
>> > >> machine you could
>> > >> >  try
>> > >> >  sending from?  Your attachments look
>> OK
>> > for
>> > >> me, but
>> > >> >  some people
>> > >> >  seem to have had problems with them.
>> > >> >
>> > >> > Oza : I used to send all from windows
>> till
>> > now.
>> > >> > but this patch I sent it from
>> Linux...from
>> > opera.
>> > >> >   2) And are you using cut-and-paste
>> to
>> > >> insert the patches
>> > >> >  into the
>> > >> >  body of your email?  That would
>> certainly
>> > >> cause
>> > >> >  problems, because
>> > >> >  tabs might be changed into spaces
>> (which
>> > is
>> > >> exactly what
>> > >> >  was
>> > >> >  causing patch to fail for me today).
>> > >> >  Oza: yes I am using copy-paste....I
>> dont
>> > know
>> > >> any-other way.
>> > >> > because attachmenet are not welcome, so
>> I am
>> > not sure
>> > >> how I could proceed with this.
>> > >>
>> > >> It's not that attachments are not welcome.
>> > >> There are various binary encodings for
>> > attachments, and
>> > >> some of those binary encodings are not
>> welcome.
>> > I
>> > >> think
>> > >> because there's no open-source way of
>> decoding
>> > them.
>> > >>
>> > >> If you look at the list, you'll see that
>> > attachments are
>> > >> used a lot.
>> > >>
>> > >> Copy-and-paste, though, in general will not
>> work,
>> > because
>> > >> it
>> > >> usually changes tabs into spaces, which ruins
>> a
>> > patch.
>> > >>
>> > >>
>> > >> > I will send you updated patch.....may be
>> I
>> > might have
>> > >> mistaken of old gdb file. sorry for
>> incovenience.
>> > >>
>> > >> I think it was just the tabs-to-spaces
>> issue.
>> > >> Why don't you try sending an attachment from
>> > Opera?
>> > >>
>> > >>
>> > >
>> > >
>> > >
>> >
>>
>>
>>
>>
>
>
>
>


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final i386.floating.record.patch
@ 2009-08-04 13:06 paawan oza
  2009-08-04 13:58 ` Hui Zhu
  0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-08-04 13:06 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Michael Snyder, gdb-patches


Hi,

As I understand you have tried to run the example test code which I had sent earlier.

please let me know at which c statement (or insn) it is causing this ?
So I can dig into it more.

Thanks & Regards,
Oza.


--- On Tue, 8/4/09, paawan oza <paawan1982@yahoo.com> wrote:

> From: paawan oza <paawan1982@yahoo.com>
> Subject: Re: final i386.floating.record.patch
> To: "Hui Zhu" <teawater@gmail.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, August 4, 2009, 6:32 PM
> Hi Hui,
> I am not sure which test case (insn)  caused this.
> would you please send me the example (.c file) which you
> have tried to run ?
> please also try to let me know at which insn (at which
> point it fails).
> Regards,
> Oza.
> 
> --- On Tue, 8/4/09, Hui Zhu <teawater@gmail.com>
> wrote:
> 
> > From: Hui Zhu <teawater@gmail.com>
> > Subject: Re: final i386.floating.record.patch
> > To: "paawan oza" <paawan1982@yahoo.com>
> > Cc: "Michael Snyder" <msnyder@vmware.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> > Date: Tuesday, August 4, 2009, 8:49 AM
> > Hi Paawan,
> > 
> > Thanks for your work.
> > 
> > I do a some test works with the test code that you
> sent in
> > before.
> > I get the values of fp reg with command "info
> > all-registers".
> > 
> > It looks like some fp reg's values not right in
> replay
> > mode.
> > 
> > In record mode they are:
> > fctrl         
> > 0x37f    895
> > fstat         
> > 0x0    0
> > ftag       
> >    0xffff    65535
> > fiseg         
> > 0x0    0
> > fioff         
> > 0x0    0
> > ---Type <return> to continue, or q
> <return> to
> > quit---
> > foseg         
> > 0x0    0
> > fooff         
> > 0x0    0
> > fop           
> > 0x0    0
> > 
> > In replay mode they are:
> > fctrl         
> > 0x37f    895
> > fstat         
> > 0x6069    24681
> > ftag       
> >    0x557f    21887
> > fiseg         
> > 0x73    115
> > fioff         
> > 0x8048bfd    134515709
> > ---Type <return> to continue, or q
> <return> to
> > quit---
> > foseg         
> > 0x7b    123
> > fooff         
> > 0x0    0
> > fop           
> > 0x2e9    745
> > 
> > 
> > 
> > Thanks,
> > Hui
> > 
> > 
> > #include <stdio.h>
> > #include <math.h>
> > #include <stdlib.h>
> > 
> > /* the test intends to test following insns.
> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
> fsubrp
> > fucomp fnstsw fsqrt
> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
> fldl2t
> > fldl2e FLDPI
> > FLDLG2 FLDLN2
> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
> frndint
> > fscale fsin fcos fcmovb
> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
> fstsw
> > */
> > 
> > float no1,no2,no3,no4,no5,no6,no7;
> > double x = 100.345, y = 25.7789;
> > long double ldx = 88888888888888888888.88, ldy =
> > 9999999999999999999.99;
> > float result,resultd,resultld;
> > float *float_memory;
> > 
> > /* initialization of floats */
> > void init_floats()
> > {
> >  no1 = 10.45;
> >  no2 = 20.77;
> >  no3 = 156.89874646;
> >  no4 = 14.56;
> >  no5 = 11.11;
> >  no6 = 66.77;
> >  no7 = 88.88;
> >  float_memory = malloc(sizeof(float) * 4);
> >  *float_memory = 256.256;
> >  *(float_memory + 1) = 356.356;
> >  *(float_memory + 2) = 456.456;
> >  *(float_memory + 3) = 556.556;
> > }
> > 
> > /* marks FPU stack as empty */
> > void empty_fpu_stack()
> > {
> >  asm ("ffree %st(1) \n\t"
> >       "ffree %st(2) \n\t"
> >       "ffree %st(3) \n\t"
> >       "ffree %st(4) \n\t"
> >       "ffree %st(5) \n\t"
> >       "ffree %st(6) \n\t"
> >       "ffree %st(7)");
> > }
> > 
> > /* tests floating point arithmatic */
> > void test_arith_floats()
> > {
> >  result = no1 + no2 + no3 + no4 + no5 + no6 +
> no7;
> >  printf("result is %f\n",result);
> > 
> >  result = fmodf(no2,no1);
> >  printf("result is %f\n",result);
> > 
> >  resultd = fmod(x,y);
> >  printf("result is %f\n",resultd);
> > 
> >  resultld = fmodl(ldy,ldy);
> >  printf("result is %f\n",resultld);
> > 
> >  result = fabsf(no1);
> >  printf("result is %f\n",result);
> > 
> >  result = no3 / no4;
> >  printf("result is %f\n",result);
> > 
> >  result = no1 * no2 * no3 * no4;
> >  printf("result is %f\n",result);
> > 
> >  result = no1 - no2 - no3 - no4;
> >  printf("result is %f\n",result);
> > 
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fchs");
> > 
> >  /* test for f2xm1 */
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("f2xm1");
> > 
> >  asm ("fyl2x");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fxtract");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fprem1");
> > 
> >  /* decrement fpu stack pointer only status
> register should
> > get affected */
> >  asm ("fld %0" : :"m"(*float_memory));
> > 
> >  empty_fpu_stack();
> > 
> >  asm ("fld1");
> >  asm ("fldl2t");
> >  asm ("fldl2e");
> >  asm ("fldpi");
> >  asm ("fldlg2");
> >  asm ("fldln2");
> >  asm ("fldz");
> > 
> >  empty_fpu_stack();
> >  /* finishing emptying the stack */
> > 
> >  result = sqrt(no3);
> >  printf("result is %f\n",result);
> > }
> > 
> > void test_log_exp_floats()
> > {
> >  result = log10(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = log(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = exp10(no3);
> >  printf("result is %f\n",result);
> > 
> >  result = exp(no3);
> >  printf("result is %f\n",result);
> > }
> > 
> > void test_trigo_floats()
> > {
> >  result = sin(30);
> >  printf("result is %f\n",result);
> > 
> >  result = cos(30);
> >  printf("result is %f\n",result);
> > 
> >  result = tan(30);
> >  printf("result is %f\n",result);
> > 
> >  result = atan(30);
> >  printf("result is %f\n",result);
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fptan");
> > 
> >  /* changes st1 and popping register stack */
> >  asm ("fpatan");
> > 
> >  asm("fincstp");
> >  asm ("fld %0" : :"m"(float_memory));
> >  asm ("fsincos");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("frndint");
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >  asm ("fscale");
> > 
> >  empty_fpu_stack();
> > 
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fsin");
> >  asm ("fcos");
> > 
> >  /* currently we assume condition likely and
> always record
> > the registers
> >  code could be optimized only if the flag is set
> then
> > record */
> >  asm ("fld %0" : :"m"(*float_memory));
> >  asm ("fld %0" : :"m"(*(float_memory+1)));
> >  asm ("fcmovb %st(1), %st");
> >  asm ("fcmovbe %st(1), %st");
> >  asm ("fcmove %st(1), %st");
> >  asm ("fcmovu %st(1), %st");
> >  asm ("fcmovnb %st(1), %st");
> >  asm ("fcmovnbe %st(1), %st");
> > 
> >  empty_fpu_stack();
> >  /* finished emtyping the stack */
> > }
> > 
> > void test_compare_floats()
> > {
> >    ldy = 88888888888888888888.88;
> >    if (ldx == ldy)
> >      ldy =
> > 7777777777777777777777777777.777;
> >    else
> >      ldy =
> > 666666666666666666666666666.666;
> > }
> > 
> > /* test loading and saving of FPU environment */
> > void test_fpu_env()
> > {
> >  asm ("fsave %0" : "=m"(*float_memory) : );
> >  asm ("frstor %0" : : "m"(*float_memory));
> >  asm ("fstsw %ax");
> > }
> > 
> > int main()
> > {
> >    init_floats();
> >    test_arith_floats();
> >    test_log_exp_floats();
> >    test_trigo_floats();
> >    test_compare_floats();
> >    test_fpu_env();
> > }
> > 
> > 
> > 
> > 
> > On Mon, Aug 3, 2009 at 22:56, paawan oza<paawan1982@yahoo.com>
> > wrote:
> > > Hi,
> > >
> > > please find the patch attached. I have attached
> as per
> > your suggestion.
> > > I am attaching it from opera browser.
> > >
> > > Regards,
> > > Oza.
> > >
> > > --- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com>
> > wrote:
> > >
> > >> From: Michael Snyder <msnyder@vmware.com>
> > >> Subject: Re: final  
> i386.floating.record.patch
> > >> To: "paawan oza" <paawan1982@yahoo.com>
> > >> Cc: "gdb-patches@sourceware.org"
> > <gdb-patches@sourceware.org>
> > >> Date: Thursday, July 30, 2009, 11:31 PM
> > >> paawan oza wrote:
> > >> > Hi,
> > >> >
> > >> > please find my answers below.
> > >> >
> > >> >  1) Are you using a Windows machine to
> send
> > your
> > >> >  emails?  If so,
> > >> >  is it possible that there is a
> Unix/Linux
> > >> machine you could
> > >> >  try
> > >> >  sending from?  Your attachments look
> OK
> > for
> > >> me, but
> > >> >  some people
> > >> >  seem to have had problems with them.
> > >> >
> > >> > Oza : I used to send all from windows
> till
> > now.
> > >> > but this patch I sent it from
> Linux...from
> > opera.
> > >> >   2) And are you using cut-and-paste
> to
> > >> insert the patches
> > >> >  into the
> > >> >  body of your email?  That would
> certainly
> > >> cause
> > >> >  problems, because
> > >> >  tabs might be changed into spaces
> (which
> > is
> > >> exactly what
> > >> >  was
> > >> >  causing patch to fail for me today).
> > >> >  Oza: yes I am using copy-paste....I
> dont
> > know
> > >> any-other way.
> > >> > because attachmenet are not welcome, so
> I am
> > not sure
> > >> how I could proceed with this.
> > >>
> > >> It's not that attachments are not welcome.
> > >> There are various binary encodings for
> > attachments, and
> > >> some of those binary encodings are not
> welcome. 
> > I
> > >> think
> > >> because there's no open-source way of
> decoding
> > them.
> > >>
> > >> If you look at the list, you'll see that
> > attachments are
> > >> used a lot.
> > >>
> > >> Copy-and-paste, though, in general will not
> work,
> > because
> > >> it
> > >> usually changes tabs into spaces, which ruins
> a
> > patch.
> > >>
> > >>
> > >> > I will send you updated patch.....may be
> I
> > might have
> > >> mistaken of old gdb file. sorry for
> incovenience.
> > >>
> > >> I think it was just the tabs-to-spaces
> issue.
> > >> Why don't you try sending an attachment from
> > Opera?
> > >>
> > >>
> > >
> > >
> > >
> > 
> 
> 
> 
> 


     


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-08-03 14:59   ` paawan oza
@ 2009-08-03 20:07     ` Michael Snyder
  0 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-08-03 20:07 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches

paawan oza wrote:
> Hi,
> 
> please let me know once you integrate the test cases.

Not sure what you mean.  I'm not working on any test cases.
I only sent a short one to you, to help you get started.

> I will also try to finish integrating test cases.

Let us know if you have any questions on that.

> So I can move to next development such as 
> i386 MMX support, because currently gdb doesnt have that.
> 
> and this time I make sure that we do not haev formatting problems
> because now I am aware what open source expects. : )

Yes, your last patch looks very nice in that respect.
Congratulations.  ;-)


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-30  6:24 ` Michael Snyder
  2009-07-30 18:09   ` paawan oza
@ 2009-08-03 14:59   ` paawan oza
  2009-08-03 20:07     ` Michael Snyder
  1 sibling, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-08-03 14:59 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches


Hi,

please let me know once you integrate the test cases. I will also try to finish integrating test cases.
So I can move to next development such as 
i386 MMX support, because currently gdb doesnt have that.

and this time I make sure that we do not haev formatting problems
because now I am aware what open source expects. : )

Regards,
Oza.


--- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final   i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Thursday, July 30, 2009, 6:06 AM
> paawan oza wrote:
> > Hi Michael,
> > 
> > Mu understanding about the patch Acceptance is ;
> > when I integrate relevant test cases regading the
> patch to the gdb test suite then it could go to mainline.
> > correct ?
> 
> That, plus I'm hoping that once we get past the formatting
> and attachment difficulties, we can get a little more
> technical
> review from the other maintainers.
> 
> > For that I am wrorking on expect scripting, soon I
> will integrate some test cases related to patch.
> 
> How's that going for you?  I hope my example was
> helpful.
> I know the dejagnu framework is pretty hard to get started
> in.
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-30 18:00       ` paawan oza
@ 2009-07-30 21:13         ` Michael Snyder
  0 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-30 21:13 UTC (permalink / raw)
  To: paawan oza; +Cc: gdb-patches

paawan oza wrote:
> Hi,
> 
> please find my answers below.
> 
>  1) Are you using a Windows machine to send your
>  emails?  If so,
>  is it possible that there is a Unix/Linux machine you could
>  try
>  sending from?  Your attachments look OK for me, but
>  some people
>  seem to have had problems with them.
> 
> Oza : I used to send all from windows till now.
> but this patch I sent it from Linux...from opera.
>  
>  2) And are you using cut-and-paste to insert the patches
>  into the
>  body of your email?  That would certainly cause
>  problems, because
>  tabs might be changed into spaces (which is exactly what
>  was
>  causing patch to fail for me today).
>  
> Oza: yes I am using copy-paste....I dont know any-other way.
> because attachmenet are not welcome, so I am not sure how I could proceed with this.

It's not that attachments are not welcome.
There are various binary encodings for attachments, and
some of those binary encodings are not welcome.  I think
because there's no open-source way of decoding them.

If you look at the list, you'll see that attachments are used a lot.

Copy-and-paste, though, in general will not work, because it
usually changes tabs into spaces, which ruins a patch.


> I will send you updated patch.....may be I might have mistaken of old gdb file. sorry for incovenience.

I think it was just the tabs-to-spaces issue.
Why don't you try sending an attachment from Opera?


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-30  6:24 ` Michael Snyder
@ 2009-07-30 18:09   ` paawan oza
  2009-08-03 14:59   ` paawan oza
  1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-30 18:09 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches


Hi,

I am trying to insatall expect and tcl...but expect gave some compilation error on suse.

mostly I tested this patch at an instruction level. 
So I am pretty confident about this patch, that I have not missed any single floating point instruction. : )

Regards,
Oza.


--- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final   i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Thursday, July 30, 2009, 6:06 AM
> paawan oza wrote:
> > Hi Michael,
> > 
> > Mu understanding about the patch Acceptance is ;
> > when I integrate relevant test cases regading the
> patch to the gdb test suite then it could go to mainline.
> > correct ?
> 
> That, plus I'm hoping that once we get past the formatting
> and attachment difficulties, we can get a little more
> technical
> review from the other maintainers.
> 
> > For that I am wrorking on expect scripting, soon I
> will integrate some test cases related to patch.
> 
> How's that going for you?  I hope my example was
> helpful.
> I know the dejagnu framework is pretty hard to get started
> in.
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-30  0:44     ` Michael Snyder
@ 2009-07-30 18:00       ` paawan oza
  2009-07-30 21:13         ` Michael Snyder
  0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-30 18:00 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches


Hi,

please find my answers below.

 1) Are you using a Windows machine to send your
 emails?  If so,
 is it possible that there is a Unix/Linux machine you could
 try
 sending from?  Your attachments look OK for me, but
 some people
 seem to have had problems with them.

Oza : I used to send all from windows till now.
but this patch I sent it from Linux...from opera.
 
 2) And are you using cut-and-paste to insert the patches
 into the
 body of your email?  That would certainly cause
 problems, because
 tabs might be changed into spaces (which is exactly what
 was
 causing patch to fail for me today).
 
Oza: yes I am using copy-paste....I dont know any-other way.
because attachmenet are not welcome, so I am not sure how I could proceed with this.

I will send you updated patch.....may be I might have mistaken of old gdb file. sorry for incovenience.

Regards,
Oza.





 
> 

--- On Thu, 7/30/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: final   i386.floating.record.patch
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Thursday, July 30, 2009, 6:03 AM
> Michael Snyder wrote:
> > paawan oza wrote:
> >> Hi All,
> >>
> >> Now the format is modified, and I am submitting
> the patch, I hope this meets the expectations.
> >> thank you all for your review comments specially
> Micahel and Hui.
> >> please find the patch as follows.
> > 
> > I'm sorry, Oza, but the patch does not apply.
> > 
> > bash-3.00$ patch <
> ~/oza3/i386.floating.record.patch.txt
> > patching file i386-tdep.c
> > Hunk #3 succeeded at 4249 with fuzz 1.
> > Hunk #4 FAILED at 4263.
> > Hunk #5 FAILED at 4321.
> > Hunk #6 FAILED at 4330.
> > Hunk #7 FAILED at 4351.
> > Hunk #8 FAILED at 4362.
> > Hunk #9 FAILED at 4414.
> > Hunk #10 FAILED at 4451.
> > Hunk #11 FAILED at 4470.
> > Hunk #12 FAILED at 4489.
> > Hunk #13 FAILED at 5110.
> > 10 out of 13 hunks FAILED -- saving rejects to file
> i386-tdep.c.rej
> 
> Just thinking about it -- this was the first time that I
> had
> trouble applying one of your patches.  But I
> remembered that
> previously, I always applied your patch from the
> attachment.
> This time there was no attachment, so I saved the email
> message
> and edited out the email headers.
> 
> I know you've had a lot of trouble with attachments and
> patches
> not applying -- I'd like to get it sorted out if possible.
> 
 1) Are you using a Windows machine to send your
 emails?  If so,
 is it possible that there is a Unix/Linux machine you could
 try
 sending from?  Your attachments look OK for me, but
 some people
 seem to have had problems with them.
 
 2) And are you using cut-and-paste to insert the patches
 into the
 body of your email?  That would certainly cause
 problems, because
 tabs might be changed into spaces (which is exactly what
 was
 causing patch to fail for me today).
 
 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-29 18:34 paawan oza
@ 2009-07-30  6:24 ` Michael Snyder
  2009-07-30 18:09   ` paawan oza
  2009-08-03 14:59   ` paawan oza
  0 siblings, 2 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-30  6:24 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches

paawan oza wrote:
> Hi Michael,
> 
> Mu understanding about the patch Acceptance is ;
> when I integrate relevant test cases regading the patch to the gdb test suite then it could go to mainline.
> correct ?

That, plus I'm hoping that once we get past the formatting and 
attachment difficulties, we can get a little more technical
review from the other maintainers.

> For that I am wrorking on expect scripting, soon I will integrate some test cases related to patch.

How's that going for you?  I hope my example was helpful.
I know the dejagnu framework is pretty hard to get started in.


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-29 22:01   ` Michael Snyder
@ 2009-07-30  0:44     ` Michael Snyder
  2009-07-30 18:00       ` paawan oza
  0 siblings, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-07-30  0:44 UTC (permalink / raw)
  To: paawan oza; +Cc: gdb-patches

Michael Snyder wrote:
> paawan oza wrote:
>> Hi All,
>>
>> Now the format is modified, and I am submitting the patch, I hope this meets the expectations.
>> thank you all for your review comments specially Micahel and Hui.
>> please find the patch as follows.
> 
> I'm sorry, Oza, but the patch does not apply.
> 
> bash-3.00$ patch < ~/oza3/i386.floating.record.patch.txt
> patching file i386-tdep.c
> Hunk #3 succeeded at 4249 with fuzz 1.
> Hunk #4 FAILED at 4263.
> Hunk #5 FAILED at 4321.
> Hunk #6 FAILED at 4330.
> Hunk #7 FAILED at 4351.
> Hunk #8 FAILED at 4362.
> Hunk #9 FAILED at 4414.
> Hunk #10 FAILED at 4451.
> Hunk #11 FAILED at 4470.
> Hunk #12 FAILED at 4489.
> Hunk #13 FAILED at 5110.
> 10 out of 13 hunks FAILED -- saving rejects to file i386-tdep.c.rej

Just thinking about it -- this was the first time that I had
trouble applying one of your patches.  But I remembered that
previously, I always applied your patch from the attachment.
This time there was no attachment, so I saved the email message
and edited out the email headers.

I know you've had a lot of trouble with attachments and patches
not applying -- I'd like to get it sorted out if possible.

1) Are you using a Windows machine to send your emails?  If so,
is it possible that there is a Unix/Linux machine you could try
sending from?  Your attachments look OK for me, but some people
seem to have had problems with them.

2) And are you using cut-and-paste to insert the patches into the
body of your email?  That would certainly cause problems, because
tabs might be changed into spaces (which is exactly what was
causing patch to fail for me today).



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
  2009-07-29 18:30 ` final i386.floating.record.patch paawan oza
@ 2009-07-29 22:01   ` Michael Snyder
  2009-07-30  0:44     ` Michael Snyder
  0 siblings, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-07-29 22:01 UTC (permalink / raw)
  To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches

paawan oza wrote:
> Hi All,
> 
> Now the format is modified, and I am submitting the patch, I hope this meets the expectations.
> thank you all for your review comments specially Micahel and Hui.
> please find the patch as follows.

I'm sorry, Oza, but the patch does not apply.

bash-3.00$ patch < ~/oza3/i386.floating.record.patch.txt
patching file i386-tdep.c
Hunk #3 succeeded at 4249 with fuzz 1.
Hunk #4 FAILED at 4263.
Hunk #5 FAILED at 4321.
Hunk #6 FAILED at 4330.
Hunk #7 FAILED at 4351.
Hunk #8 FAILED at 4362.
Hunk #9 FAILED at 4414.
Hunk #10 FAILED at 4451.
Hunk #11 FAILED at 4470.
Hunk #12 FAILED at 4489.
Hunk #13 FAILED at 5110.
10 out of 13 hunks FAILED -- saving rejects to file i386-tdep.c.rej


> 
> **********
> ChangeLog
> **********
> Current: gdb-6.8.50.20090729
> 2009-07-29  Oza  <paawan1982@yahoo.com>
> 
>         * i386-tdep.c: Support for floating point recording.
> 
> ******
> README
> ******
> Patch description:
> 
> -> Provides floating point support for i386  (reversible debugging:record-replay)
> -> previously gdb was not recording floating point registers, now all the floating point registers which are likely to be changed by floating   point instructions, are recorded and replayed.
> -> the patch intends to provide the full support for all i386 floating point instructions.
> 
> 
> *****
> patch
> *****
> 
> diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- gdb.orig/i386-tdep.c        2009-07-29 19:48:51.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-07-29 19:51:08.000000000 -0400
> @@ -3139,6 +3139,66 @@
>    return 0;
>  }
> 
> +
> +/* Defines contents to record.  */
> +#define I386_SAVE_FPU_REGS              0xfffd
> +#define I386_SAVE_FPU_ENV               0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
> +
> +/* Record the value of floating point registers which will be changed by the
> +   current instruction to "record_arch_list".  Return -1 if something is wrong.
> +*/
> +
> +static int i386_record_floats (struct gdbarch *gdbarch,
> +                               struct i386_record_s *ir,
> +                               uint32_t iregnum)
> +{
> +  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> +  int i;
> +
> +  /* Oza: Because of floating point insn push/pop of fpu stack is going to
> +     happen.  Currently we store st0-st7 registers, but we need not store all
> +     registers all the time, in future we use ftag register and record only
> +     those who are not marked as an empty.  */
> +
> +  if (I386_SAVE_FPU_REGS == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
> +        {
> +          if (record_arch_list_add_reg (ir->regcache, i))
> +            return -1;
> +        }
> +    }
> +  else if (I386_SAVE_FPU_ENV == iregnum)
> +    {
> +      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> +       {
> +         if (record_arch_list_add_reg (ir->regcache, i))
> +           return -1;
> +       }
> +    }
> +  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> +      {
> +        if (record_arch_list_add_reg (ir->regcache, i))
> +          return -1;
> +      }
> +    }
> +  else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
> +           (iregnum <= I387_FOP_REGNUM (tdep)))
> +    {
> +      if (record_arch_list_add_reg (ir->regcache,iregnum))
> +        return -1;
> +    }
> +  else
> +    {
> +      /* Parameter error.  */
> +      return -1;
> +    }
> +  return 0;
> +}
> +
>  /* Parse the current instruction and record the values of the registers and
>     memory that will be changed in current instruction to "record_arch_list".
>     Return -1 if something wrong. */
> @@ -3153,6 +3213,7 @@
>    uint32_t tmpu32;
>    uint32_t opcode;
>    struct i386_record_s ir;
> +  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> 
>    memset (&ir, 0, sizeof (struct i386_record_s));
>    ir.regcache = regcache;
> @@ -4188,8 +4249,7 @@
>         }
>        break;
> 
> -      /* floats */
> -      /* It just record the memory change of instrcution. */
> +    /* Floats.  */
>      case 0xd8:
>      case 0xd9:
>      case 0xda:
> @@ -4203,45 +4263,56 @@
>        ir.reg |= ((opcode & 7) << 3);
>        if (ir.mod != 3)
>         {
> -         /* memory */
> +         /* Memory.  */
>           uint32_t addr;
> 
>           if (i386_record_lea_modrm_addr (&ir, &addr))
>             return -1;
>           switch (ir.reg)
>             {
> -           case 0x00:
> -           case 0x01:
>             case 0x02:
> +            case 0x12:
> +            case 0x22:
> +            case 0x32:
> +              /* For fcom, ficom nothing to do.  */
> +              break;
>             case 0x03:
> +            case 0x13:
> +            case 0x23:
> +            case 0x33:
> +              /* For fcomp, ficomp pop FPU stack, store all.  */
> +              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                return -1;
> +              break;
> +            case 0x00:
> +            case 0x01:
>             case 0x04:
>             case 0x05:
>             case 0x06:
>             case 0x07:
>             case 0x10:
>             case 0x11:
> -           case 0x12:
> -           case 0x13:
>             case 0x14:
>             case 0x15:
>             case 0x16:
>             case 0x17:
>             case 0x20:
>             case 0x21:
> -           case 0x22:
> -           case 0x23:
>             case 0x24:
>             case 0x25:
>             case 0x26:
>             case 0x27:
>             case 0x30:
>             case 0x31:
> -           case 0x32:
> -           case 0x33:
>             case 0x34:
>             case 0x35:
>             case 0x36:
>             case 0x37:
> +              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
> +                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
> +                 of code,  always affects st(0) register.  */
> +              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> +                return -1;
>               break;
>             case 0x08:
>             case 0x0a:
> @@ -4250,6 +4321,7 @@
>             case 0x19:
>             case 0x1a:
>             case 0x1b:
> +            case 0x1d:
>             case 0x28:
>             case 0x29:
>             case 0x2a:
> @@ -4258,9 +4330,14 @@
>             case 0x39:
>             case 0x3a:
>             case 0x3b:
> +            case 0x3c:
> +            case 0x3d:
>               switch (ir.reg & 7)
>                 {
>                 case 0:
> +                 /* Handling fld, fild.  */
> +                 if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                   return -1;
>                   break;
>                 case 1:
>                   switch (ir.reg >> 4)
> @@ -4274,6 +4351,7 @@
>                         return -1;
>                       break;
>                     case 3:
> +                     break;
>                     default:
>                       if (record_arch_list_add_mem (addr, 2))
>                         return -1;
> @@ -4284,15 +4362,49 @@
>                   switch (ir.reg >> 4)
>                     {
>                     case 0:
> +                     if (record_arch_list_add_mem (addr, 4))
> +                       return -1;
> +                     if (3 == (ir.reg & 7))
> +                       {
> +                         /* For fstp m32fp.  */
> +                         if (i386_record_floats (gdbarch, &ir,
> +                                                 I386_SAVE_FPU_REGS))
> +                           return -1;
> +                       }
> +                     break;
>                     case 1:
>                       if (record_arch_list_add_mem (addr, 4))
>                         return -1;
> +                     if ((3 == (ir.reg & 7))
> +                         || (5 == (ir.reg & 7))
> +                         || (7 == (ir.reg & 7)))
> +                       {
> +                         /* For fstp insn.  */
> +                         if (i386_record_floats (gdbarch, &ir,
> +                                                 I386_SAVE_FPU_REGS))
> +                           return -1;
> +                       }
>                       break;
>                     case 2:
>                       if (record_arch_list_add_mem (addr, 8))
>                         return -1;
> +                     if (3 == (ir.reg & 7))
> +                       {
> +                         /* For fstp m64fp.  */
> +                         if (i386_record_floats (gdbarch, &ir,
> +                                                 I386_SAVE_FPU_REGS))
> +                           return -1;
> +                       }
>                       break;
>                     case 3:
> +                     if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
> +                       {
> +                         /* For fistp, fbld, fild, fbstp.  */
> +                         if (i386_record_floats (gdbarch, &ir,
> +                                                 I386_SAVE_FPU_REGS))
> +                           return -1;
> +                       }
> +                     /* Fall through */
>                     default:
>                       if (record_arch_list_add_mem (addr, 2))
>                         return -1;
> @@ -4302,11 +4414,21 @@
>                 }
>               break;
>             case 0x0c:
> +              /* Insn fldenv.  */
> +              if (i386_record_floats (gdbarch, &ir,
> +                                      I386_SAVE_FPU_ENV_REG_STACK))
> +                return -1;
> +              break;
>             case 0x0d:
> -           case 0x1d:
> +              /* Insn fldcw.  */
> +              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
> +                return -1;
> +              break;
>             case 0x2c:
> -           case 0x3c:
> -           case 0x3d:
> +              /* Insn frstor.  */
> +              if (i386_record_floats (gdbarch, &ir,
> +                                      I386_SAVE_FPU_ENV_REG_STACK))
> +                return -1;
>               break;
>             case 0x0e:
>               if (ir.dflag)
> @@ -4329,6 +4451,9 @@
>             case 0x3e:
>               if (record_arch_list_add_mem (addr, 10))
>                 return -1;
> +              /* Insn fstp, fbstp.  */
> +              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                return -1;
>               break;
>             case 0x2e:
>               if (ir.dflag)
> @@ -4345,10 +4470,17 @@
>                 }
>               if (record_arch_list_add_mem (addr, 80))
>                 return -1;
> +              /* Insn fsave.  */
> +              if (i386_record_floats (gdbarch, &ir,
> +                                      I386_SAVE_FPU_ENV_REG_STACK))
> +                return -1;
>               break;
>             case 0x3f:
>               if (record_arch_list_add_mem (addr, 8))
>                 return -1;
> +              /* Ins fistp.  */
> +              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                return -1;
>               break;
>             default:
>               ir.addr -= 2;
> @@ -4357,8 +4489,211 @@
>               break;
>             }
>         }
> +      /* Opcode is an extension of modR/M byte.  */
> +      else
> +        {
> +         switch (opcode)
> +           {
> +           case 0xd8:
> +             if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> +               return -1;
> +             break;
> +           case 0xd9:
> +             if (0x0c == (ir.modrm >> 4))
> +               {
> +                 if ((ir.modrm & 0x0f) <= 7)
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I386_SAVE_FPU_REGS))
> +                       return -1;
> +                   }
> +                  else
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep)))
> +                       return -1;
> +                     /* If only st(0) is changing, then we have already
> +                        recorded.  */
> +                     if ((ir.modrm & 0x0f) - 0x08)
> +                       {
> +                         if (i386_record_floats (gdbarch, &ir,
> +                                                 I387_ST0_REGNUM (tdep) +
> +                                                 ((ir.modrm & 0x0f) - 0x08)))
> +                           return -1;
> +                       }
> +                   }
> +               }
> +              else
> +                {
> +                 switch (ir.modrm)
> +                   {
> +                   case 0xe0:
> +                   case 0xe1:
> +                   case 0xf0:
> +                   case 0xf5:
> +                   case 0xf8:
> +                   case 0xfa:
> +                   case 0xfc:
> +                   case 0xfe:
> +                   case 0xff:
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep)))
> +                       return -1;
> +                     break;
> +                   case 0xf1:
> +                   case 0xf2:
> +                   case 0xf3:
> +                   case 0xf4:
> +                   case 0xf6:
> +                   case 0xf7:
> +                   case 0xe8:
> +                   case 0xe9:
> +                   case 0xea:
> +                   case 0xeb:
> +                   case 0xec:
> +                   case 0xed:
> +                   case 0xee:
> +                   case 0xf9:
> +                   case 0xfb:
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I386_SAVE_FPU_REGS))
> +                       return -1;
> +                     break;
> +                   case 0xfd:
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep)))
> +                       return -1;
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) + 1))
> +                       return -1;
> +                     break;
> +                   }
> +               }
> +              break;
> +            case 0xda:
> +              if (0xe9 == ir.modrm)
> +                {
> +                 if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                   return -1;
> +                }
> +              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> +                {
> +                 if (i386_record_floats (gdbarch, &ir,
> +                                         I387_ST0_REGNUM (tdep)))
> +                   return -1;
> +                 if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             (ir.modrm & 0x0f)))
> +                       return -1;
> +                   }
> +                 else if ((ir.modrm & 0x0f) - 0x08)
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             ((ir.modrm & 0x0f) - 0x08)))
> +                       return -1;
> +                   }
> +                }
> +              break;
> +            case 0xdb:
> +              if (0xe3 == ir.modrm)
> +                {
> +                 if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
> +                   return -1;
> +                }
> +              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> +                {
> +                 if (i386_record_floats (gdbarch, &ir,
> +                                         I387_ST0_REGNUM (tdep)))
> +                   return -1;
> +                 if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             (ir.modrm & 0x0f)))
> +                       return -1;
> +                   }
> +                 else if ((ir.modrm & 0x0f) - 0x08)
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             ((ir.modrm & 0x0f) - 0x08)))
> +                       return -1;
> +                   }
> +                }
> +              break;
> +            case 0xdc:
> +              if ((0x0c == ir.modrm >> 4)
> +                 || (0x0d == ir.modrm >> 4)
> +                 || (0x0f == ir.modrm >> 4))
> +                {
> +                 if ((ir.modrm & 0x0f) <= 7)
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             (ir.modrm & 0x0f)))
> +                       return -1;
> +                   }
> +                 else
> +                   {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             ((ir.modrm & 0x0f) - 0x08)))
> +                       return -1;
> +                   }
> +                }
> +             break;
> +            case 0xdd:
> +              if (0x0c == ir.modrm >> 4)
> +                {
> +                  if (i386_record_floats (gdbarch, &ir,
> +                                          I387_FTAG_REGNUM (tdep)))
> +                    return -1;
> +                }
> +              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> +                {
> +                  if ((ir.modrm & 0x0f) <= 7)
> +                    {
> +                     if (i386_record_floats (gdbarch, &ir,
> +                                             I387_ST0_REGNUM (tdep) +
> +                                             (ir.modrm & 0x0f)))
> +                       return -1;
> +                    }
> +                  else
> +                    {
> +                      if (i386_record_floats (gdbarch, &ir,
> +                                             I386_SAVE_FPU_REGS))
> +                        return -1;
> +                    }
> +                }
> +              break;
> +            case 0xde:
> +              if ((0x0c == ir.modrm >> 4)
> +                 || (0x0e == ir.modrm >> 4)
> +                 || (0x0f == ir.modrm >> 4)
> +                 || (0xd9 == ir.modrm))
> +                {
> +                 if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                   return -1;
> +                }
> +              break;
> +            case 0xdf:
> +              if (0xe0 == ir.modrm)
> +                {
> +                 if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> +                   return -1;
> +                }
> +              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> +                {
> +                 if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +                   return -1;
> +                }
> +              break;
> +           }
> +       }
>        break;
> -
>        /* string ops */
>        /* movsS */
>      case 0xa4:
> @@ -4775,12 +5110,18 @@
>        break;
> 
>        /* fwait */
> -      /* XXX */
>      case 0x9b:
> -      printf_unfiltered (_("Process record doesn't support instruction "
> -                          "fwait.\n"));
> -      ir.addr -= 1;
> -      goto no_support;
> +      if (target_read_memory (ir.addr, &tmpu8, 1))
> +        {
> +          if (record_debug)
> +            printf_unfiltered (_("Process record: error reading memory at "
> +                                "addr 0x%s len = 1.\n"),
> +                              paddress (gdbarch, ir.addr));
> +          return -1;
> +        }
> +      opcode = (uint32_t) tmpu8;
> +      ir.addr++;
> +      goto reswitch;
>        break;
> 
>        /* int3 */
> 
> 
> Regards,
> Oza.
> 
> 
> 
> 
> --- On Mon, 7/27/09, Michael Snyder <msnyder@vmware.com> wrote:
> 
>> From: Michael Snyder <msnyder@vmware.com>
>> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Hui Zhu" <teawater@gmail.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Monday, July 27, 2009, 12:34 AM
>> paawan oza wrote:
>>
>>> (please try take difference with attached files and
>> see the 'diff' result, it is strange, if you take the patch
>> on windows it gets even more worse with formatting)
>>
>> OK, I've done as you suggested.  Here are my comments
>> (search for "msnyder):
>>
>>
>> -----Inline Attachment Follows-----
>>
>>
>> --- i386-tdep.0726.c    2009-07-26
>> 10:55:37.000013000 -0700
>> +++ i386-tdep.c    2009-07-26
>> 11:00:19.001044000 -0700
>> @@ -3139,6 +3139,66 @@
>>    return 0;
>>  }
>>
>> +
>> +/* Defines contents to record.  */
>> +#define I386_SAVE_FPU_REGS
>>       0xfffd
>> +#define I386_SAVE_FPU_ENV
>>        0xfffe
>> +#define I386_SAVE_FPU_ENV_REG_STACK
>>    0xffff
>> +
>> +/* Record the value of floating point registers which will
>> be changed by the
>> +   current instruction to
>> "record_arch_list".  Return -1 if something is
>> wrong.
>> +*/
>> +
>> +static int i386_record_floats (struct gdbarch
>> *gdbarch,
>> +
>>
>>    struct i386_record_s *ir,
>> +
>>
>>    uint32_t iregnum)
>> +{
>> +  struct gdbarch_tdep *tdep = gdbarch_tdep
>> (gdbarch);
>> +  int i;
>> +
>> +  /* Oza:Because of floating point insn push/pop of
>> fpu stack is going to
>>
>> msnyder: "Oza: Because"
>>
>> +     happen.  Currently we store
>> st0-st7 registers, but we need not store all
>> +     registers all the time, in future
>> we use ftag register and record only
>> +     those who are not marked as an
>> empty.
>> +   */
>> +  if (I386_SAVE_FPU_REGS == iregnum)
>> +    {
>> +      for (i = I387_ST0_REGNUM (tdep);i
>> <= I387_ST0_REGNUM (tdep) + 7;i++)
>>
>> msynder:
>>        for (i = I387_ST0_REGNUM
>> (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
>>
>> +        {
>> +          if
>> (record_arch_list_add_reg (ir->regcache, i))
>> +            return -1;
>> +        }
>> +    }
>> +  else if (I386_SAVE_FPU_ENV == iregnum)
>> +    {
>> +      for (i = I387_FCTRL_REGNUM (tdep);i
>> <= I387_FOP_REGNUM (tdep);i++)
>>
>> msnyder:
>>        for (i = I387_FCTRL_REGNUM
>> (tdep); i <= I387_FOP_REGNUM (tdep); i++)
>>
>> +      {
>>
>> msnyder: indent { to the right by two spaces after "for".
>>
>> +        if (record_arch_list_add_reg
>> (ir->regcache, i))
>> +          return -1;
>> +      }
>> +    }
>> +  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
>> +    {
>> +      for (i = I387_ST0_REGNUM (tdep);i
>> <= I387_FOP_REGNUM (tdep);i++)
>>
>> msnyder:
>>        for (i = I387_ST0_REGNUM
>> (tdep); i <= I387_FOP_REGNUM (tdep); i++)
>>
>> +      {
>> +        if (record_arch_list_add_reg
>> (ir->regcache, i))
>> +          return -1;
>>
>> +      }
>> +    }
>> +  else if ((iregnum >= I387_ST0_REGNUM (tdep))
>> &&
>> +           (iregnum
>> <= I387_FOP_REGNUM (tdep)))
>> +    {
>> +      if (record_arch_list_add_reg
>> (ir->regcache,iregnum))
>> +        return -1;
>> +    }
>> +  else
>> +    {
>> +      /* Parameter error.  */
>> +      return -1;
>> +    }
>> +  return 0;
>> +}
>> +
>>  /* Parse the current instruction and record the values of
>> the registers and
>>     memory that will be changed in current
>> instruction to "record_arch_list".
>>     Return -1 if something wrong. */
>> @@ -3153,6 +3213,7 @@
>>    uint32_t tmpu32;
>>    uint32_t opcode;
>>    struct i386_record_s ir;
>> +  struct gdbarch_tdep *tdep = gdbarch_tdep
>> (gdbarch);
>>
>>    memset (&ir, 0, sizeof (struct
>> i386_record_s));
>>    ir.regcache = regcache;
>> @@ -4188,8 +4249,7 @@
>>      }
>>        break;
>>
>> -      /* floats */
>> -      /* It just record the memory change
>> of instrcution. */
>> +    /* Floats.  */
>>      case 0xd8:
>>      case 0xd9:
>>      case 0xda:
>> @@ -4203,45 +4263,56 @@
>>        ir.reg |= ((opcode & 7)
>> << 3);
>>        if (ir.mod != 3)
>>      {
>> -      /* memory */
>> +        /* Memory.  */
>>        uint32_t addr;
>>
>>        if (i386_record_lea_modrm_addr
>> (&ir, &addr))
>>          return -1;
>>        switch (ir.reg)
>>          {
>> -        case 0x00:
>> -        case 0x01:
>>          case 0x02:
>> +            case 0x12:
>> +            case 0x22:
>> +            case 0x32:
>> +              /* For
>> fcom, ficom nothing to do.  */
>> +              break;
>>          case 0x03:
>> +            case 0x13:
>> +            case 0x23:
>> +            case 0x33:
>> +              /* For
>> fcomp, ficomp pop FPU stack, store all.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>> return -1;
>> +              break;
>> +            case 0x00:
>> +            case 0x01:
>>          case 0x04:
>>          case 0x05:
>>          case 0x06:
>>          case 0x07:
>>          case 0x10:
>>          case 0x11:
>> -        case 0x12:
>> -        case 0x13:
>>          case 0x14:
>>          case 0x15:
>>          case 0x16:
>>          case 0x17:
>>          case 0x20:
>>          case 0x21:
>> -        case 0x22:
>> -        case 0x23:
>>          case 0x24:
>>          case 0x25:
>>          case 0x26:
>>          case 0x27:
>>          case 0x30:
>>          case 0x31:
>> -        case 0x32:
>> -        case 0x33:
>>          case 0x34:
>>          case 0x35:
>>          case 0x36:
>>          case 0x37:
>> +              /* For
>> fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
>> +
>>    fisub, fisubr, fidiv, fidivr, modR/M.reg
>> is an extension of code,
>> +
>>    always affects st(0) register.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
>> (tdep)))
>> +
>> return -1;
>>            break;
>>          case 0x08:
>>          case 0x0a:
>> @@ -4250,6 +4321,7 @@
>>          case 0x19:
>>          case 0x1a:
>>          case 0x1b:
>> +            case 0x1d:
>>          case 0x28:
>>          case 0x29:
>>          case 0x2a:
>> @@ -4258,9 +4330,14 @@
>>          case 0x39:
>>          case 0x3a:
>>          case 0x3b:
>> +            case 0x3c:
>> +            case 0x3d:
>>            switch (ir.reg
>> & 7)
>>          {
>>          case 0:
>> +
>>     /* Handling fld, fild.  */
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> I386_SAVE_FPU_REGS))
>> +
>>       return -1;
>>
>> msnyder: indented too far (two spaces extra):
>>
>>    /* Handling fld, fild.  */
>>
>>    if (i386_record_floats (gdbarch, &ir,
>> I386_SAVE_FPU_REGS))
>>
>>      return -1;
>>
>>
>>
>>            break;
>>          case 1:
>>            switch
>> (ir.reg >> 4)
>> @@ -4274,6 +4351,7 @@
>>
>> return -1;
>>
>> break;
>>              case
>> 3:
>> +
>>         break;
>>
>> msnyder: indented too far:
>>
>>        break;
>>
>>
>> default:
>>
>> if (record_arch_list_add_mem (addr, 2))
>>
>> return -1;
>> @@ -4284,15 +4362,49 @@
>>            switch
>> (ir.reg >> 4)
>>              {
>>              case
>> 0:
>> +
>>           if
>> (record_arch_list_add_mem (addr, 4))
>> +
>>             return -1;
>> +
>>           if (3 == (ir.reg &
>> 7))
>> +
>>             {
>> +
>>             /* For fstp
>> m32fp.  */
>> +
>>             if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>
>>     I386_SAVE_FPU_REGS))
>> +
>>               return
>> -1;
>>
>> +
>>             }
>> +
>>           break;
>>
>> msnyder: indented four extra spaces too far.
>>
>>
>>
>>              case
>> 1:
>>
>> if (record_arch_list_add_mem (addr, 4))
>>
>> return -1;
>> +
>>         if ((3 == (ir.reg &
>> 7))  \
>> +
>>            || (5 ==
>> (ir.reg & 7))  \
>> +
>>            || (7 ==
>> (ir.reg & 7)))
>>
>> msnyder: remove '\' from end of lines:
>>
>>
>>         if ((3 == (ir.reg & 7))
>>
>>             || (5 == (ir.reg
>> & 7))
>>
>>             || (7 == (ir.reg
>> & 7)))
>>
>>
>>
>>
>> +
>>           {
>> +
>>           /* For fstp insn.
>> */
>> +
>>             if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>
>>     I386_SAVE_FPU_REGS))
>> +
>>               return
>> -1;
>>
>> +
>>           }
>>
>> break;
>>              case
>> 2:
>>
>> if (record_arch_list_add_mem (addr, 8))
>>
>> return -1;
>> +
>>           if (3 == (ir.reg &
>> 7))
>> +
>>             {
>> +
>>             /* For fstp
>> m64fp.  */
>> +
>>             if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>
>>     I386_SAVE_FPU_REGS))
>> +
>>               return
>> -1;
>>
>> +
>>             }
>>
>> msnyder: indented too far.
>>
>>
>> break;
>>              case
>> 3:
>> +
>>           if ((3 <= (ir.reg
>> & 7)) && (6 <= (ir.reg & 7)))
>> +
>>             {
>> +
>>             /* For fistp,
>> fbld, fild, fbstp.  */
>> +
>>             if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>
>>     I386_SAVE_FPU_REGS))
>> +
>>               return
>> -1;
>>
>> +
>>             }
>> +
>>         /*Fall through */
>>
>> msnyder: indented too far.
>>
>>
>> default:
>>
>> if (record_arch_list_add_mem (addr, 2))
>>
>> return -1;
>> @@ -4302,11 +4414,21 @@
>>          }
>>            break;
>>          case 0x0c:
>> +              /* Insn
>> fldenv.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>       I386_SAVE_FPU_ENV_REG_STACK))
>> +
>> return -1;
>> +              break;
>>          case 0x0d:
>> -        case 0x1d:
>> +              /* Insn
>> fldcw.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM
>> (tdep)))
>> +
>> return -1;
>> +              break;
>>          case 0x2c:
>> -        case 0x3c:
>> -        case 0x3d:
>> +              /* Insn
>> frstor.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>       I386_SAVE_FPU_ENV_REG_STACK))
>> +
>> return -1;
>>            break;
>>          case 0x0e:
>>            if (ir.dflag)
>> @@ -4329,6 +4451,9 @@
>>          case 0x3e:
>>            if
>> (record_arch_list_add_mem (addr, 10))
>>          return -1;
>> +              /* Insn
>> fstp, fbstp.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>> return -1;
>>
>>
>>            break;
>>          case 0x2e:
>>            if (ir.dflag)
>> @@ -4345,10 +4470,17 @@
>>          }
>>            if
>> (record_arch_list_add_mem (addr, 80))
>>          return -1;
>> +              /* Insn
>> fsave.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir,
>> +
>>
>>       I386_SAVE_FPU_ENV_REG_STACK))
>> +
>> return -1;
>>            break;
>>          case 0x3f:
>>            if
>> (record_arch_list_add_mem (addr, 8))
>>          return -1;
>> +              /* Ins
>> fistp.  */
>> +              if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>> return -1;
>>            break;
>>          default:
>>            ir.addr -= 2;
>> @@ -4357,8 +4489,205 @@
>>            break;
>>          }
>>      }
>> +        /* Opcode is an extension of
>> modR/M byte.  */
>> +        else
>>
>> msnyder:  above, indentation level minus two after }
>>       /* Opcode is an extension of modR/M
>> byte.  */
>>       else
>>
>> +        {
>> +        switch (opcode)
>>
>> msnyder: above, indentation level plus two after {
>>            switch
>> (opcode)
>>
>> And then everything below this point needs to be
>> re-indented to the right.
>>
>>
>> +          {
>> +          case 0xd8:
>> +            if
>> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
>> (tdep)))
>> +              return
>> -1;
>> +            break;
>> +          case 0xd9:
>>
>> +            if (0x0c ==
>> (ir.modrm >> 4))
>> +              {
>> +                if
>> ((ir.modrm & 0x0f) <= 7)
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> I386_SAVE_FPU_REGS))
>> +
>>     return -1;
>>
>> msnyder: missing a right-indent.
>>
>> +
>>   }
>> +
>>   else
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>           I387_ST0_REGNUM (tdep)))
>>
>> msnyder: missing a right-indent.
>>
>> +
>>     return -1;
>> +
>>   /* If only st(0) is changing, then we have already
>> recorded.  */
>> +
>>   if ((ir.modrm & 0x0f) - 0x08)
>> +
>>     {
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>>
>> msnyder: missing a right-indent.
>>
>> +
>>
>>             I387_ST0_REGNUM
>> (tdep) + \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>             ((ir.modrm &
>> 0x0f) - 0x08)))
>> +
>>       return -1;
>>
>>
>> +
>>     }
>> +
>>   }
>> +              }
>> +              else
>> +                {
>>
>> msnyder: indentation.
>>
>> +
>> switch(ir.modrm)
>>
>> msnyder: "switch ("
>>
>> +
>>   {
>> +
>>   case 0xe0:
>> +
>>   case 0xe1:
>> +
>>   case 0xf0:
>> +
>>   case 0xf5:
>> +
>>   case 0xf8:
>> +
>>   case 0xfa:
>> +
>>   case 0xfc:
>> +
>>   case 0xfe:
>> +
>>   case 0xff:
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>             I387_ST0_REGNUM
>> (tdep)))
>> +
>>       return -1;
>> +
>>     break;
>>
>> +
>>   case 0xf1:
>> +
>>   case 0xf2:
>> +
>>   case 0xf3:
>> +
>>   case 0xf4:
>> +
>>   case 0xf6:
>> +
>>   case 0xf7:
>> +
>>   case 0xe8:
>> +
>>   case 0xe9:
>> +
>>   case 0xea:
>> +
>>   case 0xeb:
>> +
>>   case 0xec:
>> +
>>   case 0xed:
>> +
>>   case 0xee:
>> +
>>   case 0xf9:
>> +
>>   case 0xfb:
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> I386_SAVE_FPU_REGS))
>> +
>>       return -1;
>> +
>>     break;
>> +
>>   case 0xfd:
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>             I387_ST0_REGNUM
>> (tdep)))
>> +
>>       return -1;
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>             I387_ST0_REGNUM
>> (tdep) + 1))
>> +
>>       return -1;
>> +
>>     break;
>> +
>>   }
>> +              }
>> +              break;
>> +            case 0xda:
>> +              if (0xe9
>> == ir.modrm)
>> +                {
>> +                if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>>   return -1;
>>
>>
>> msnyder: indentation after {
>>
>> +                }
>> +              else if
>> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
>> 4))
>> +                {
>> +                if
>> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
>> (tdep)))
>>
>> msnyder: indentation after {
>>
>> +
>>   return -1;
>>
>> +                if
>> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
>> 0x0f) <= 7))
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>>
>> msnyder: indentation after {
>>
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>           (ir.modrm & 0x0f)))
>> +
>>     return -1;
>>
>>
>> +
>>   }
>> +
>> else if ((ir.modrm & 0x0f) - 0x08)
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>> \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>>
>> +
>>
>>           ((ir.modrm & 0x0f) -
>> 0x08)))
>> +
>>     return -1;
>> +
>>   }
>> +
>> }
>> +              break;
>> +            case 0xdb:
>> +              if (0xe3
>> == ir.modrm)
>> +                {
>> +                if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
>>
>> msnyder: indentation after {
>>
>> +
>>   return -1;
>>
>> +                }
>> +              else if
>> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
>> 4))
>> +                {
>> +                if
>> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
>> (tdep)))
>>
>> msnyder: indentation after {
>>
>> +
>>   return -1;
>>
>> +                if
>> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
>> 0x0f) <= 7))
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>>
>> msnyder: indentation after {
>>
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>> \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>           (ir.modrm & 0x0f)))
>> +
>>     return -1;
>>
>>
>> +
>>   }
>> +
>> else if ((ir.modrm & 0x0f) - 0x08)
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>>
>> msnyder: indentation after {
>>
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>> \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>           ((ir.modrm & 0x0f) -
>> 0x08)))
>> +
>>     return -1;
>> +
>>   }
>> +
>> }
>> +              break;
>> +            case 0xdc:
>> +              if ((0x0c
>> == ir.modrm >> 4)    \
>> +
>>    || (0x0d == ir.modrm >> 4)  \
>> +
>>    || (0x0f == ir.modrm >> 4))
>>
>> msnyder: no \ at end of line.
>>
>>    if ((0x0c == ir.modrm >> 4)
>>
>>    || (0x0d == ir.modrm >> 4)
>>
>>    || (0x0f == ir.modrm >> 4))
>>
>> +                {
>> +                if
>> ((ir.modrm & 0x0f) <= 7)
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>> \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>           (ir.modrm & 0x0f)))
>> +
>>     return -1;
>>
>>
>> +
>>   }
>> +
>> else
>> +
>>   {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>           I387_ST0_REGNUM (tdep) +
>> \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>           ((ir.modrm & 0x0f) -
>> 0x08)))
>> +
>>     return -1;
>> +
>>   }
>> +
>> }
>> +
>>    break;
>> +            case 0xdd:
>>
>> +              if (0x0c
>> == ir.modrm >> 4)
>> +                {
>> +
>>   if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>           I387_FTAG_REGNUM
>> (tdep)))
>> +
>>     return -1;
>> +                }
>> +              else if
>> ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >>
>> 4))
>> +                {
>>
>> +
>>   if ((ir.modrm & 0x0f) <= 7)
>> +
>>     {
>> +
>>     if (i386_record_floats (gdbarch, &ir,
>> +
>>
>>             I387_ST0_REGNUM
>> (tdep) + \
>>
>> msnyder: no \ at end of line.
>>
>>
>>
>>    I387_ST0_REGNUM (tdep) +
>>
>> +
>>
>>             (ir.modrm &
>> 0x0f)))
>> +
>>       return
>> -1;
>> +
>>     }
>> +
>>   else
>> +
>>     {
>> +
>>       if (i386_record_floats (gdbarch,
>> &ir, I386_SAVE_FPU_REGS))
>> +
>>         return -1;
>> +
>>     }
>> +
>> }
>> +              break;
>> +            case 0xde:
>> +              if ((0x0c
>> == ir.modrm >> 4)  \
>> +
>>    || (0x0e == ir.modrm >> 4)  \
>> +
>>    || (0x0f == ir.modrm >> 4)  \
>> +
>>    || (0xd9 == ir.modrm))
>>
>> msnyder: no \ at end of line.
>>
>>    if ((0x0c == ir.modrm >> 4)
>>
>>    || (0x0e == ir.modrm >> 4)
>>
>>    || (0x0f == ir.modrm >> 4)
>>
>>    || (0xd9 == ir.modrm))
>>
>>
>> +
>> {
>>
>> +                if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>>   return -1;
>> +
>> }
>> +              break;
>> +            case 0xdf:
>> +              if (0xe0
>> == ir.modrm)
>> +                {
>> +                if
>> (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
>> +
>>   return -1;
>> +                }
>> +              else if
>> ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >>
>> 4))
>> +                {
>>
>> +                if
>> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
>> +
>>   return -1;
>> +                }
>>
>> +              break;
>> +          }
>>
>> +      }
>>
>>        break;
>> -
>>        /* string ops */
>>        /* movsS */
>>      case 0xa4:
>> @@ -4777,10 +5106,17 @@
>>        /* fwait */
>>        /* XXX */
>>      case 0x9b:
>> -      printf_unfiltered (_("Process record
>> doesn't support instruction "
>> -
>>    "fwait.\n"));
>> -      ir.addr -= 1;
>> -      goto no_support;
>> +      if (target_read_memory (ir.addr,
>> &tmpu8, 1))
>> +        {
>> +          if (record_debug)
>> +
>> printf_unfiltered (_("Process record: error reading memory
>> at "
>> +
>>
>>
>>         "addr 0x%s len = 1.\n"),
>> +
>>
>>    paddress (gdbarch, ir.addr));
>>
>> msnyder: indentation
>>
>>    printf_unfiltered (_("Process record:
>> error reading memory at "
>>
>>
>>   "addr 0x%s len = 1.\n"),
>>
>>
>> paddress (gdbarch, ir.addr));
>>
>> +          return -1;
>> +        }
>> +      opcode = (uint32_t) tmpu8;
>> +      ir.addr++;
>> +      goto reswitch;
>>
>>        break;
>>
>>        /* int3 */
>>
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: final   i386.floating.record.patch
@ 2009-07-29 18:34 paawan oza
  2009-07-30  6:24 ` Michael Snyder
  0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-29 18:34 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches


Hi Michael,

Mu understanding about the patch Acceptance is ;
when I integrate relevant test cases regading the patch to the gdb test suite then it could go to mainline.
correct ?

For that I am wrorking on expect scripting, soon I will integrate some test cases related to patch.

Regards,
Oza.



--- On Wed, 7/29/09, paawan oza <paawan1982@yahoo.com> wrote:

> From: paawan oza <paawan1982@yahoo.com>
> Subject: final   i386.floating.record.patch
> To: "Michael Snyder" <msnyder@vmware.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Wednesday, July 29, 2009, 8:45 PM
> Hi All,
> 
> Now the format is modified, and I am submitting the patch,
> I hope this meets the expectations.
> thank you all for your review comments specially Micahel
> and Hui.
> please find the patch as follows. 
> 
> **********
> ChangeLog
> **********
> Current: gdb-6.8.50.20090729
> 2009-07-29  Oza  <paawan1982@yahoo.com>
> 
>         * i386-tdep.c: Support for
> floating point recording.
> 
> ******
> README
> ******
> Patch description:
> 
> -> Provides floating point support for i386 
> (reversible debugging:record-replay)
> -> previously gdb was not recording floating point
> registers, now all the floating point registers which are
> likely to be changed by floating   point
> instructions, are recorded and replayed.
> -> the patch intends to provide the full support for all
> i386 floating point instructions.
> 
> 
> *****
> patch
> *****
> 
> diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- gdb.orig/i386-tdep.c    2009-07-29
> 19:48:51.000000000 -0400
> +++ gdb.new/i386-tdep.c    2009-07-29
> 19:51:08.000000000 -0400
> @@ -3139,6 +3139,66 @@
>    return 0;
>  }
>  
> +
> +/* Defines contents to record.  */
> +#define I386_SAVE_FPU_REGS       
>       0xfffd
> +#define I386_SAVE_FPU_ENV       
>        0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK 
>    0xffff
> +
> +/* Record the value of floating point registers which will
> be changed by the
> +   current instruction to
> "record_arch_list".  Return -1 if something is
> wrong.  
> +*/  
> +
> +static int i386_record_floats (struct gdbarch
> *gdbarch,  
> +               
>            
>    struct i386_record_s *ir,  
> +               
>            
>    uint32_t iregnum)
> +{
> +  struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
> +  int i;
> +
> +  /* Oza: Because of floating point insn push/pop of
> fpu stack is going to 
> +     happen.  Currently we store
> st0-st7 registers, but we need not store all 
> +     registers all the time, in future
> we use ftag register and record only 
> +     those who are not marked as an
> empty.  */
> +
> +  if (I386_SAVE_FPU_REGS == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep); i
> <= I387_ST0_REGNUM (tdep) + 7; i++)
> +        {
> +          if
> (record_arch_list_add_reg (ir->regcache, i))
> +            return -1;
> +        }
> +    }
> +  else if (I386_SAVE_FPU_ENV == iregnum)
> +    {
> +      for (i = I387_FCTRL_REGNUM (tdep); i
> <= I387_FOP_REGNUM (tdep); i++)
> +    {
> +      if (record_arch_list_add_reg
> (ir->regcache, i))
> +        return -1;
> +    }
> +    }
> +  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep); i
> <= I387_FOP_REGNUM (tdep); i++)
> +      {
> +        if (record_arch_list_add_reg
> (ir->regcache, i))
> +          return -1;
> +      }
> +    }
> +  else if ((iregnum >= I387_ST0_REGNUM (tdep))
> && 
> +           (iregnum
> <= I387_FOP_REGNUM (tdep)))
> +    {
> +      if (record_arch_list_add_reg
> (ir->regcache,iregnum))
> +        return -1;
> +    }
> +  else
> +    {
> +      /* Parameter error.  */
> +      return -1;
> +    }
> +  return 0;
> +}
> +
>  /* Parse the current instruction and record the values of
> the registers and
>     memory that will be changed in current
> instruction to "record_arch_list".
>     Return -1 if something wrong. */
> @@ -3153,6 +3213,7 @@
>    uint32_t tmpu32;
>    uint32_t opcode;
>    struct i386_record_s ir;
> +  struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
>  
>    memset (&ir, 0, sizeof (struct
> i386_record_s));
>    ir.regcache = regcache;
> @@ -4188,8 +4249,7 @@
>      }
>        break;
>  
> -      /* floats */
> -      /* It just record the memory change
> of instrcution. */
> +    /* Floats.  */
>      case 0xd8:
>      case 0xd9:
>      case 0xda:
> @@ -4203,45 +4263,56 @@
>        ir.reg |= ((opcode & 7)
> << 3);
>        if (ir.mod != 3)
>      {
> -      /* memory */
> +      /* Memory.  */
>        uint32_t addr;
>  
>        if (i386_record_lea_modrm_addr
> (&ir, &addr))
>          return -1;
>        switch (ir.reg)
>          {
> -        case 0x00:
> -        case 0x01:
>          case 0x02:
> +            case 0x12:
> +            case 0x22:
> +            case 0x32:
> +              /* For
> fcom, ficom nothing to do.  */
> +              break;
>          case 0x03:
> +            case 0x13:
> +            case 0x23:
> +            case 0x33:
> +              /* For
> fcomp, ficomp pop FPU stack, store all.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;
> +              break;
> +            case 0x00:
> +            case 0x01:
>          case 0x04:
>          case 0x05:
>          case 0x06:
>          case 0x07:
>          case 0x10:
>          case 0x11:
> -        case 0x12:
> -        case 0x13:
>          case 0x14:
>          case 0x15:
>          case 0x16:
>          case 0x17:
>          case 0x20:
>          case 0x21:
> -        case 0x22:
> -        case 0x23:
>          case 0x24:
>          case 0x25:
>          case 0x26:
>          case 0x27:
>          case 0x30:
>          case 0x31:
> -        case 0x32:
> -        case 0x33:
>          case 0x34:
>          case 0x35:
>          case 0x36:
>          case 0x37:
> +              /* For
> fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
> +             
>    fisub, fisubr, fidiv, fidivr, modR/M.reg
> is an extension
> +             
>    of code,  always affects st(0)
> register.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +               
> return -1;
>            break;
>          case 0x08:
>          case 0x0a:
> @@ -4250,6 +4321,7 @@
>          case 0x19:
>          case 0x1a:
>          case 0x1b:
> +            case 0x1d: 
>          case 0x28:
>          case 0x29:
>          case 0x2a:
> @@ -4258,9 +4330,14 @@
>          case 0x39:
>          case 0x3a:
>          case 0x3b:
> +            case 0x3c: 
> +            case 0x3d: 
>            switch (ir.reg
> & 7)
>          {
>          case 0:
> +          /* Handling
> fld, fild.  */
> +          if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +            return
> -1;
>            break;
>          case 1:
>            switch
> (ir.reg >> 4)
> @@ -4274,6 +4351,7 @@
>             
> return -1;
>               
> break;
>              case
> 3:
> +             
> break;
>             
> default:
>               
> if (record_arch_list_add_mem (addr, 2))
>             
> return -1;
> @@ -4284,15 +4362,49 @@
>            switch
> (ir.reg >> 4)
>              {
>              case
> 0:
> +             
> if (record_arch_list_add_mem (addr, 4))
> +           
> return -1;
> +             
> if (3 == (ir.reg & 7))
> +           
> {
> +           
>   /* For fstp m32fp.  */
> +           
>   if (i386_record_floats (gdbarch, &ir, 
> +           
>            
>   I386_SAVE_FPU_REGS))
> +           
>     return -1;
> +           
> }
> +             
> break;
>              case
> 1:
>               
> if (record_arch_list_add_mem (addr, 4))
>             
> return -1;
> +             
> if ((3 == (ir.reg & 7))
> +           
>   || (5 == (ir.reg & 7))
> +           
>   || (7 == (ir.reg & 7)))
> +           
> {
> +           
>   /* For fstp insn.  */
> +           
>   if (i386_record_floats (gdbarch, &ir, 
> +           
>            
>   I386_SAVE_FPU_REGS))
> +           
>     return -1;
> +           
> }
>               
> break;
>              case
> 2:
>               
> if (record_arch_list_add_mem (addr, 8))
>             
> return -1;
> +             
> if (3 == (ir.reg & 7))
> +           
> {
> +           
>   /* For fstp m64fp.  */
> +           
>   if (i386_record_floats (gdbarch, &ir, 
> +           
>            
>   I386_SAVE_FPU_REGS))
> +           
>     return -1;
> +           
> }
>               
> break;
>              case
> 3:
> +             
> if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg
> & 7)))
> +           
> {
> +           
>   /* For fistp, fbld, fild, fbstp.  */
> +           
>   if (i386_record_floats (gdbarch, &ir, 
> +           
>            
>   I386_SAVE_FPU_REGS))
> +           
>     return -1;
> +           
> }
> +             
> /* Fall through */  
>             
> default:
>               
> if (record_arch_list_add_mem (addr, 2))
>             
> return -1;
> @@ -4302,11 +4414,21 @@
>          }
>            break;
>          case 0x0c:
> +              /* Insn
> fldenv.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;
> +              break;
>          case 0x0d:
> -        case 0x1d:
> +              /* Insn
> fldcw.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM
> (tdep)))
> +               
> return -1;
> +              break;
>          case 0x2c:
> -        case 0x3c:
> -        case 0x3d:
> +              /* Insn
> frstor.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;
>            break;
>          case 0x0e:
>            if (ir.dflag)
> @@ -4329,6 +4451,9 @@
>          case 0x3e:
>            if
> (record_arch_list_add_mem (addr, 10))
>          return -1;
> +              /* Insn
> fstp, fbstp.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;
>            break;
>          case 0x2e:
>            if (ir.dflag)
> @@ -4345,10 +4470,17 @@
>          }
>            if
> (record_arch_list_add_mem (addr, 80))
>          return -1;
> +              /* Insn
> fsave.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;
>            break;
>          case 0x3f:
>            if
> (record_arch_list_add_mem (addr, 8))
>          return -1;
> +              /* Ins
> fistp.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;
>            break;
>          default:
>            ir.addr -= 2;
> @@ -4357,8 +4489,211 @@
>            break;
>          }
>      }
> +      /* Opcode is an extension of modR/M
> byte.  */     
> +      else
> +        { 
> +      switch (opcode)
> +        {
> +        case 0xd8:
> +          if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +        return
> -1;    
> +          break;
> +        case 0xd9:    
> +          if (0x0c ==
> (ir.modrm >> 4))
> +        {
> +          if ((ir.modrm
> & 0x0f) <= 7)
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I386_SAVE_FPU_REGS))
> +           
> return -1;    
> +            }
> +               
>   else
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep)))
> +           
> return -1;    
> +             
> /* If only st(0) is changing, then we have already 
> +       
>      recorded.  */
> +             
> if ((ir.modrm & 0x0f) - 0x08)
> +           
> {
> +           
>   if (i386_record_floats (gdbarch, &ir, 
> +           
>            
>   I387_ST0_REGNUM (tdep) +
> +           
>            
>   ((ir.modrm & 0x0f) - 0x08)))
> +           
>     return -1;       
>                
>   
> +           
> }
> +            }
> +        }
> +              else
> +                {
> +          switch
> (ir.modrm)
> +            {
> +            case
> 0xe0:
> +            case
> 0xe1:
> +            case
> 0xf0:
> +            case
> 0xf5:
> +            case
> 0xf8:
> +            case
> 0xfa:
> +            case
> 0xfc:
> +            case
> 0xfe:
> +            case
> 0xff:
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep)))
> +           
> return -1;
> +             
> break;
> +            case
> 0xf1:
> +            case
> 0xf2:
> +            case
> 0xf3:
> +            case
> 0xf4:
> +            case
> 0xf6:
> +            case
> 0xf7:
> +            case
> 0xe8:
> +            case
> 0xe9:
> +            case
> 0xea:
> +            case
> 0xeb:
> +            case
> 0xec:
> +            case
> 0xed:
> +            case
> 0xee:
> +            case
> 0xf9:
> +            case
> 0xfb:
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I386_SAVE_FPU_REGS))
> +           
> return -1;
> +             
> break;
> +            case
> 0xfd:
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep)))
> +           
> return -1;
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) + 1))
> +           
> return -1;
> +             
> break;
> +            }
> +        }
> +              break;
> +            case 0xda:
> +              if (0xe9
> == ir.modrm)
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +            return
> -1;
> +                }
> +              else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, 
> +           
>           I387_ST0_REGNUM
> (tdep)))
> +            return
> -1;
> +          if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) + 
> +           
>              
> (ir.modrm & 0x0f)))
> +           
> return -1;
> +            }
> +          else if
> ((ir.modrm & 0x0f) - 0x08)
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> ((ir.modrm & 0x0f) - 0x08)))
> +           
> return -1;
> +            }
> +                }
> +              break;
> +            case 0xdb:
> +              if (0xe3
> == ir.modrm)
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
> +            return
> -1;
> +                }
> +              else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, 
> +           
>           I387_ST0_REGNUM
> (tdep)))
> +            return
> -1;
> +          if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> (ir.modrm & 0x0f)))
> +           
> return -1;
> +            }
> +          else if
> ((ir.modrm & 0x0f) - 0x08)
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir,
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> ((ir.modrm & 0x0f) - 0x08)))
> +           
> return -1;
> +            }
> +                }
> +              break;
> +            case 0xdc:
> +              if ((0x0c
> == ir.modrm >> 4)
> +          || (0x0d ==
> ir.modrm >> 4)
> +          || (0x0f ==
> ir.modrm >> 4))
> +                {
> +          if ((ir.modrm
> & 0x0f) <= 7)
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> (ir.modrm & 0x0f)))
> +           
> return -1;
> +            }
> +          else
> +            {
> +             
> if (i386_record_floats (gdbarch, &ir,
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> ((ir.modrm & 0x0f) - 0x08)))
> +           
> return -1;
> +            }
> +                }
> +          break;
> +            case 0xdd:
> +              if (0x0c
> == ir.modrm >> 4)
> +                {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_FTAG_REGNUM
> (tdep)))
> +               
>     return -1;
> +                }
> +              else if
> ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> +                {
> +               
>   if ((ir.modrm & 0x0f) <= 7)
> +               
>     {
> +             
> if (i386_record_floats (gdbarch, &ir, 
> +           
>              
> I387_ST0_REGNUM (tdep) +
> +           
>              
> (ir.modrm & 0x0f)))
> +           
> return -1;
> +               
>     }
> +               
>   else
> +               
>     {
> +               
>       if (i386_record_floats (gdbarch,
> &ir, 
> +           
>              
> I386_SAVE_FPU_REGS))
> +               
>         return -1;
> +               
>     }
> +                }
> +              break;
> +            case 0xde:
> +              if ((0x0c
> == ir.modrm >> 4)
> +          || (0x0e ==
> ir.modrm >> 4)
> +          || (0x0f ==
> ir.modrm >> 4)
> +          || (0xd9 ==
> ir.modrm))
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +            return
> -1;     
> +                }
> +              break;
> +            case 0xdf:
> +              if (0xe0
> == ir.modrm)
> +                {
> +          if
> (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> +            return
> -1;
> +                }
> +              else if
> ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> +                {
> +          if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +            return
> -1;
> +                }
> +              break;
> +        }
> +    }
>        break;
> -
>        /* string ops */
>        /* movsS */
>      case 0xa4:
> @@ -4775,12 +5110,18 @@
>        break;
>  
>        /* fwait */
> -      /* XXX */
>      case 0x9b:
> -      printf_unfiltered (_("Process record
> doesn't support instruction "
> -           
>    "fwait.\n"));
> -      ir.addr -= 1;
> -      goto no_support;
> +      if (target_read_memory (ir.addr,
> &tmpu8, 1))
> +        {
> +          if (record_debug)
> +           
> printf_unfiltered (_("Process record: error reading memory
> at "
> +           
>      "addr 0x%s len = 1.\n"),
> +           
>        paddress (gdbarch,
> ir.addr));
> +          return -1;
> +        }
> +      opcode = (uint32_t) tmpu8;
> +      ir.addr++;
> +      goto reswitch; 
>    
>        break;
>  
>        /* int3 */
> 
> 
> Regards,
> Oza.
> 
> 
> 
> 
> --- On Mon, 7/27/09, Michael Snyder <msnyder@vmware.com>
> wrote:
> 
> > From: Michael Snyder <msnyder@vmware.com>
> > Subject: Re: i386.record.floating.point.patch : with
> more testing and assurity
> > To: "paawan oza" <paawan1982@yahoo.com>
> > Cc: "Hui Zhu" <teawater@gmail.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "pedro@codesourcery.com"
> <pedro@codesourcery.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> > Date: Monday, July 27, 2009, 12:34 AM
> > paawan oza wrote:
> > 
> > > (please try take difference with attached files
> and
> > see the 'diff' result, it is strange, if you take the
> patch
> > on windows it gets even more worse with formatting)
> > 
> > OK, I've done as you suggested.  Here are my
> comments
> > (search for "msnyder):
> > 
> > 
> > -----Inline Attachment Follows-----
> > 
> > 
> > --- i386-tdep.0726.c    2009-07-26
> > 10:55:37.000013000 -0700
> > +++ i386-tdep.c    2009-07-26
> > 11:00:19.001044000 -0700
> > @@ -3139,6 +3139,66 @@
> >    return 0;
> >  }
> >  
> > +
> > +/* Defines contents to record.  */
> > +#define I386_SAVE_FPU_REGS       
> >       0xfffd
> > +#define I386_SAVE_FPU_ENV       
> >        0xfffe
> > +#define I386_SAVE_FPU_ENV_REG_STACK 
> >    0xffff
> > +
> > +/* Record the value of floating point registers which
> will
> > be changed by the
> > +   current instruction to
> > "record_arch_list".  Return -1 if something is
> > wrong.  
> > +*/  
> > +
> > +static int i386_record_floats (struct gdbarch
> > *gdbarch,  
> > +               
> >            
> >    struct i386_record_s *ir,  
> > +               
> >            
> >    uint32_t iregnum)
> > +{
> > +  struct gdbarch_tdep *tdep = gdbarch_tdep
> > (gdbarch);
> > +  int i;
> > +
> > +  /* Oza:Because of floating point insn push/pop of
> > fpu stack is going to 
> > 
> > msnyder: "Oza: Because"
> > 
> > +     happen.  Currently we store
> > st0-st7 registers, but we need not store all 
> > +     registers all the time, in future
> > we use ftag register and record only 
> > +     those who are not marked as an
> > empty.  
> > +   */
> > +  if (I386_SAVE_FPU_REGS == iregnum)
> > +    {
> > +      for (i = I387_ST0_REGNUM (tdep);i
> > <= I387_ST0_REGNUM (tdep) + 7;i++)
> > 
> > msynder:
> >        for (i = I387_ST0_REGNUM
> > (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
> > 
> > +        {
> > +          if
> > (record_arch_list_add_reg (ir->regcache, i))
> > +            return -1;
> > +        }
> > +    }
> > +  else if (I386_SAVE_FPU_ENV == iregnum)
> > +    {
> > +      for (i = I387_FCTRL_REGNUM (tdep);i
> > <= I387_FOP_REGNUM (tdep);i++)
> > 
> > msnyder:
> >        for (i = I387_FCTRL_REGNUM
> > (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> > 
> > +      {
> > 
> > msnyder: indent { to the right by two spaces after
> "for".
> > 
> > +        if (record_arch_list_add_reg
> > (ir->regcache, i))
> > +          return -1;
> > +      }
> > +    }
> > +  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> > +    {
> > +      for (i = I387_ST0_REGNUM (tdep);i
> > <= I387_FOP_REGNUM (tdep);i++)
> > 
> > msnyder:
> >        for (i = I387_ST0_REGNUM
> > (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> > 
> > +      {
> > +        if (record_arch_list_add_reg
> > (ir->regcache, i))
> > +          return -1;   
> > 
> > +      }
> > +    }
> > +  else if ((iregnum >= I387_ST0_REGNUM (tdep))
> > && 
> > +           (iregnum
> > <= I387_FOP_REGNUM (tdep)))
> > +    {
> > +      if (record_arch_list_add_reg
> > (ir->regcache,iregnum))
> > +        return -1;
> > +    }
> > +  else
> > +    {
> > +      /* Parameter error.  */
> > +      return -1;
> > +    } 
> > +  return 0;
> > +}
> > +
> >  /* Parse the current instruction and record the
> values of
> > the registers and
> >     memory that will be changed in current
> > instruction to "record_arch_list".
> >     Return -1 if something wrong. */
> > @@ -3153,6 +3213,7 @@
> >    uint32_t tmpu32;
> >    uint32_t opcode;
> >    struct i386_record_s ir;
> > +  struct gdbarch_tdep *tdep = gdbarch_tdep
> > (gdbarch);
> >  
> >    memset (&ir, 0, sizeof (struct
> > i386_record_s));
> >    ir.regcache = regcache;
> > @@ -4188,8 +4249,7 @@
> >      }
> >        break;
> >  
> > -      /* floats */
> > -      /* It just record the memory change
> > of instrcution. */
> > +    /* Floats.  */
> >      case 0xd8:
> >      case 0xd9:
> >      case 0xda:
> > @@ -4203,45 +4263,56 @@
> >        ir.reg |= ((opcode & 7)
> > << 3);
> >        if (ir.mod != 3)
> >      {
> > -      /* memory */
> > +        /* Memory.  */
> >        uint32_t addr;
> >  
> >        if (i386_record_lea_modrm_addr
> > (&ir, &addr))
> >          return -1;
> >        switch (ir.reg)
> >          {
> > -        case 0x00:
> > -        case 0x01:
> >          case 0x02:
> > +            case 0x12:
> > +            case 0x22:
> > +            case 0x32:
> > +              /* For
> > fcom, ficom nothing to do.  */
> > +              break;
> >          case 0x03:
> > +            case 0x13:
> > +            case 0x23:
> > +            case 0x33:
> > +              /* For
> > fcomp, ficomp pop FPU stack, store all.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> > return -1;
> > +              break;
> > +            case 0x00:
> > +            case 0x01:
> >          case 0x04:
> >          case 0x05:
> >          case 0x06:
> >          case 0x07:
> >          case 0x10:
> >          case 0x11:
> > -        case 0x12:
> > -        case 0x13:
> >          case 0x14:
> >          case 0x15:
> >          case 0x16:
> >          case 0x17:
> >          case 0x20:
> >          case 0x21:
> > -        case 0x22:
> > -        case 0x23:
> >          case 0x24:
> >          case 0x25:
> >          case 0x26:
> >          case 0x27:
> >          case 0x30:
> >          case 0x31:
> > -        case 0x32:
> > -        case 0x33:
> >          case 0x34:
> >          case 0x35:
> >          case 0x36:
> >          case 0x37:
> > +              /* For
> > fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
> > +             
> >    fisub, fisubr, fidiv, fidivr, modR/M.reg
> > is an extension of code, 
> > +             
> >    always affects st(0) register.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir,
> I387_ST0_REGNUM
> > (tdep)))
> > +               
> > return -1;
> >            break;
> >          case 0x08:
> >          case 0x0a:
> > @@ -4250,6 +4321,7 @@
> >          case 0x19:
> >          case 0x1a:
> >          case 0x1b:
> > +            case 0x1d: 
> >          case 0x28:
> >          case 0x29:
> >          case 0x2a:
> > @@ -4258,9 +4330,14 @@
> >          case 0x39:
> >          case 0x3a:
> >          case 0x3b:
> > +            case 0x3c: 
> > +            case 0x3d: 
> >            switch (ir.reg
> > & 7)
> >          {
> >          case 0:
> > +               
> >     /* Handling fld, fild.  */
> > +               
> >     if (i386_record_floats (gdbarch, &ir,
> > I386_SAVE_FPU_REGS))
> > +               
> >       return -1;    
> > 
> > msnyder: indented too far (two spaces extra):
> >                
> >    /* Handling fld, fild.  */
> >                
> >    if (i386_record_floats (gdbarch, &ir,
> > I386_SAVE_FPU_REGS))
> >                
> >      return -1;    
> > 
> > 
> > 
> >            break;
> >          case 1:
> >            switch
> > (ir.reg >> 4)
> > @@ -4274,6 +4351,7 @@
> >             
> > return -1;
> >               
> > break;
> >              case
> > 3:
> > +               
> >         break;
> > 
> > msnyder: indented too far:
> >                
> >        break;
> > 
> >             
> > default:
> >               
> > if (record_arch_list_add_mem (addr, 2))
> >             
> > return -1;
> > @@ -4284,15 +4362,49 @@
> >            switch
> > (ir.reg >> 4)
> >              {
> >              case
> > 0:
> > +               
> >           if
> > (record_arch_list_add_mem (addr, 4))
> > +               
> >             return -1;
> > +               
> >           if (3 == (ir.reg &
> > 7))
> > +               
> >             {
> > +               
> >             /* For fstp
> > m32fp.  */
> > +               
> >             if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >                
> >     I386_SAVE_FPU_REGS))
> > +               
> >               return
> > -1;               
> >         
> > +               
> >             } 
> > +               
> >           break;
> > 
> > msnyder: indented four extra spaces too far.
> > 
> > 
> > 
> >              case
> > 1:
> >               
> > if (record_arch_list_add_mem (addr, 4))
> >             
> > return -1;
> > +               
> >         if ((3 == (ir.reg &
> > 7))  \
> > +               
> >            || (5 ==
> > (ir.reg & 7))  \
> > +               
> >            || (7 ==
> > (ir.reg & 7)))
> > 
> > msnyder: remove '\' from end of lines:
> > 
> >                
> >         if ((3 == (ir.reg & 7))
> >                
> >             || (5 == (ir.reg
> > & 7))
> >                
> >             || (7 == (ir.reg
> > & 7)))
> > 
> > 
> > 
> > 
> > +               
> >           {
> > +               
> >           /* For fstp insn. 
> > */
> > +               
> >             if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >                
> >     I386_SAVE_FPU_REGS))
> > +               
> >               return
> > -1;               
> >         
> > +               
> >           } 
> >               
> > break;
> >              case
> > 2:
> >               
> > if (record_arch_list_add_mem (addr, 8))
> >             
> > return -1;
> > +               
> >           if (3 == (ir.reg &
> > 7))
> > +               
> >             {
> > +               
> >             /* For fstp
> > m64fp.  */
> > +               
> >             if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >                
> >     I386_SAVE_FPU_REGS))
> > +               
> >               return
> > -1;               
> >         
> > +               
> >             } 
> > 
> > msnyder: indented too far.
> > 
> >               
> > break;
> >              case
> > 3:
> > +               
> >           if ((3 <= (ir.reg
> > & 7)) && (6 <= (ir.reg & 7)))
> > +               
> >             {
> > +               
> >             /* For fistp,
> > fbld, fild, fbstp.  */
> > +               
> >             if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >                
> >     I386_SAVE_FPU_REGS))
> > +               
> >               return
> > -1;               
> >         
> > +               
> >             }  
> > +               
> >         /*Fall through */  
> > 
> > msnyder: indented too far.
> > 
> >             
> > default:
> >               
> > if (record_arch_list_add_mem (addr, 2))
> >             
> > return -1;
> > @@ -4302,11 +4414,21 @@
> >          }
> >            break;
> >          case 0x0c:
> > +              /* Insn
> > fldenv.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >       I386_SAVE_FPU_ENV_REG_STACK))
> > +               
> > return -1;  
> > +              break;
> >          case 0x0d:
> > -        case 0x1d:
> > +              /* Insn
> > fldcw.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir,
> I387_FCTRL_REGNUM
> > (tdep)))
> > +               
> > return -1;  
> > +              break;
> >          case 0x2c:
> > -        case 0x3c:
> > -        case 0x3d:
> > +              /* Insn
> > frstor.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >       I386_SAVE_FPU_ENV_REG_STACK))
> > +               
> > return -1;  
> >            break;
> >          case 0x0e:
> >            if (ir.dflag)
> > @@ -4329,6 +4451,9 @@
> >          case 0x3e:
> >            if
> > (record_arch_list_add_mem (addr, 10))
> >          return -1;
> > +              /* Insn
> > fstp, fbstp.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> > return -1;             
> >                
> >     
> >            break;
> >          case 0x2e:
> >            if (ir.dflag)
> > @@ -4345,10 +4470,17 @@
> >          }
> >            if
> > (record_arch_list_add_mem (addr, 80))
> >          return -1;
> > +              /* Insn
> > fsave.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >       I386_SAVE_FPU_ENV_REG_STACK))
> > +               
> > return -1;   
> >            break;
> >          case 0x3f:
> >            if
> > (record_arch_list_add_mem (addr, 8))
> >          return -1;
> > +              /* Ins
> > fistp.  */
> > +              if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> > return -1;   
> >            break;
> >          default:
> >            ir.addr -= 2;
> > @@ -4357,8 +4489,205 @@
> >            break;
> >          }
> >      }
> > +        /* Opcode is an extension of
> > modR/M byte.  */     
> > +        else
> > 
> > msnyder:  above, indentation level minus two after }
> >       /* Opcode is an extension of modR/M
> > byte.  */     
> >       else
> > 
> > +        { 
> > +        switch (opcode)
> > 
> > msnyder: above, indentation level plus two after {
> >            switch
> > (opcode)
> > 
> > And then everything below this point needs to be
> > re-indented to the right.
> > 
> > 
> > +          {
> > +          case 0xd8:
> > +            if
> > (i386_record_floats (gdbarch, &ir,
> I387_ST0_REGNUM
> > (tdep)))
> > +              return
> > -1;    
> > +            break;
> > +          case 0xd9:   
> > 
> > +            if (0x0c ==
> > (ir.modrm >> 4))
> > +              {
> > +                if
> > ((ir.modrm & 0x0f) <= 7)
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir,
> > I386_SAVE_FPU_REGS))
> > +               
> >     return -1;    
> > 
> > msnyder: missing a right-indent.
> > 
> > +               
> >   }
> > +               
> >   else
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep)))
> > 
> > msnyder: missing a right-indent.
> > 
> > +               
> >     return -1;    
> > +               
> >   /* If only st(0) is changing, then we have already
> > recorded.  */
> > +               
> >   if ((ir.modrm & 0x0f) - 0x08)
> > +               
> >     {
> > +               
> >     if (i386_record_floats (gdbarch, &ir, 
> > 
> > msnyder: missing a right-indent.
> > 
> > +               
> >                
> >             I387_ST0_REGNUM
> > (tdep) + \
> > 
> > msnyder: no \ at end of line.
> > 
> >                
> >                
> >          
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >             ((ir.modrm &
> > 0x0f) - 0x08)))
> > +               
> >       return -1;     
> >                
> >     
> > +               
> >     } 
> > +               
> >   }  
> > +              }
> > +              else
> > +                {
> > 
> > msnyder: indentation.
> > 
> > +               
> > switch(ir.modrm)
> > 
> > msnyder: "switch ("
> > 
> > +               
> >   {
> > +               
> >   case 0xe0:
> > +               
> >   case 0xe1:
> > +               
> >   case 0xf0:
> > +               
> >   case 0xf5:
> > +               
> >   case 0xf8:
> > +               
> >   case 0xfa:
> > +               
> >   case 0xfc:
> > +               
> >   case 0xfe:
> > +               
> >   case 0xff:
> > +               
> >     if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >             I387_ST0_REGNUM
> > (tdep)))
> > +               
> >       return -1;
> > +               
> >     break;       
> >    
> > +               
> >   case 0xf1:  
> > +               
> >   case 0xf2:  
> > +               
> >   case 0xf3:  
> > +               
> >   case 0xf4:
> > +               
> >   case 0xf6: 
> > +               
> >   case 0xf7:    
> > +               
> >   case 0xe8:  
> > +               
> >   case 0xe9:  
> > +               
> >   case 0xea:  
> > +               
> >   case 0xeb:
> > +               
> >   case 0xec:        
> > +               
> >   case 0xed:    
> > +               
> >   case 0xee:   
> > +               
> >   case 0xf9:     
> > +               
> >   case 0xfb:
> > +               
> >     if (i386_record_floats (gdbarch, &ir,
> > I386_SAVE_FPU_REGS))
> > +               
> >       return -1;    
> > +               
> >     break;
> > +               
> >   case 0xfd: 
> > +               
> >     if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >             I387_ST0_REGNUM
> > (tdep)))
> > +               
> >       return -1;
> > +               
> >     if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >             I387_ST0_REGNUM
> > (tdep) + 1))
> > +               
> >       return -1;
> > +               
> >     break;
> > +               
> >   } 
> > +              }
> > +              break;
> > +            case 0xda:
> > +              if (0xe9
> > == ir.modrm)
> > +                {
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> >   return -1;           
> >         
> > 
> > msnyder: indentation after {
> > 
> > +                }
> > +              else if
> > ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm
> >>
> > 4))
> > +                {
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I387_ST0_REGNUM
> > (tdep)))
> > 
> > msnyder: indentation after {
> > 
> > +               
> >   return -1;         
> >           
> > +                if
> > (((ir.modrm & 0x0f) > 0) && ((ir.modrm
> &
> > 0x0f) <= 7))
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > 
> > msnyder: indentation after {
> > 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >           (ir.modrm & 0x0f)))
> > +               
> >     return -1;       
> >                
> >   
> > +               
> >   }
> > +               
> > else if ((ir.modrm & 0x0f) - 0x08)
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >        
> >    I387_ST0_REGNUM (tdep) +
> > 
> > 
> > +               
> >                
> >           ((ir.modrm & 0x0f) -
> > 0x08)))
> > +               
> >     return -1;
> > +               
> >   }
> > +               
> > }  
> > +              break; 
> > +            case 0xdb:
> > +              if (0xe3
> > == ir.modrm)
> > +                {
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_ENV))
> > 
> > msnyder: indentation after {
> > 
> > +               
> >   return -1;           
> >         
> > +                }
> > +              else if
> > ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm
> >>
> > 4))
> > +                {
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I387_ST0_REGNUM
> > (tdep)))
> > 
> > msnyder: indentation after {
> > 
> > +               
> >   return -1;         
> >           
> > +                if
> > (((ir.modrm & 0x0f) > 0) && ((ir.modrm
> &
> > 0x0f) <= 7))
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > 
> > msnyder: indentation after {
> > 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >        
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >           (ir.modrm & 0x0f)))
> > +               
> >     return -1;       
> >                
> >   
> > +               
> >   }
> > +               
> > else if ((ir.modrm & 0x0f) - 0x08)
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > 
> > msnyder: indentation after {
> > 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >        
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >           ((ir.modrm & 0x0f) -
> > 0x08)))
> > +               
> >     return -1;
> > +               
> >   }
> > +               
> > }  
> > +              break;
> > +            case 0xdc:
> > +              if ((0x0c
> > == ir.modrm >> 4)    \
> > +             
> >    || (0x0d == ir.modrm >> 4)  \
> > +             
> >    || (0x0f == ir.modrm >> 4))
> > 
> > msnyder: no \ at end of line.
> >            
> >    if ((0x0c == ir.modrm >> 4)
> >                
> >    || (0x0d == ir.modrm >> 4)
> >                
> >    || (0x0f == ir.modrm >> 4))
> > 
> > +                {
> > +                if
> > ((ir.modrm & 0x0f) <= 7)
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >        
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >           (ir.modrm & 0x0f)))
> > +               
> >     return -1;       
> >                
> >   
> > +               
> >   }
> > +               
> > else
> > +               
> >   {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >           I387_ST0_REGNUM (tdep) +
> > \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >        
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >           ((ir.modrm & 0x0f) -
> > 0x08)))
> > +               
> >     return -1;
> > +               
> >   }
> > +               
> > }  
> > +           
> >    break;
> > +            case 0xdd: 
> >            
> > +              if (0x0c
> > == ir.modrm >> 4)
> > +                {
> > +               
> >   if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >           I387_FTAG_REGNUM
> > (tdep)))
> > +               
> >     return -1;
> > +                }
> > +              else if
> > ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm
> >>
> > 4))
> > +                {
> > 
> > +               
> >   if ((ir.modrm & 0x0f) <= 7)
> > +               
> >     {
> > +               
> >     if (i386_record_floats (gdbarch, &ir, 
> > +               
> >                
> >             I387_ST0_REGNUM
> > (tdep) + \
> > 
> > msnyder: no \ at end of line.
> >                
> >                
> >          
> >    I387_ST0_REGNUM (tdep) +
> > 
> > +               
> >                
> >             (ir.modrm &
> > 0x0f)))
> > +               
> >       return
> > -1;     
> > +               
> >     }
> > +               
> >   else
> > +               
> >     {
> > +               
> >       if (i386_record_floats (gdbarch,
> > &ir, I386_SAVE_FPU_REGS))
> > +               
> >         return -1;
> > +               
> >     }
> > +               
> > }            
> > +              break;
> > +            case 0xde:
> > +              if ((0x0c
> > == ir.modrm >> 4)  \
> > +             
> >    || (0x0e == ir.modrm >> 4)  \
> > +             
> >    || (0x0f == ir.modrm >> 4)  \
> > +             
> >    || (0xd9 == ir.modrm))
> > 
> > msnyder: no \ at end of line.
> >            
> >    if ((0x0c == ir.modrm >> 4)
> >                
> >    || (0x0e == ir.modrm >> 4)
> >                
> >    || (0x0f == ir.modrm >> 4)
> >                
> >    || (0xd9 == ir.modrm))
> > 
> > 
> > +               
> > {               
> >    
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> >   return -1;     
> > +               
> > }   
> > +              break;
> > +            case 0xdf:
> > +              if (0xe0
> > == ir.modrm)
> > +                {
> > +                if
> > (record_arch_list_add_reg (ir.regcache,
> I386_EAX_REGNUM))
> > +               
> >   return -1;
> > +                }
> > +              else if
> > ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm
> >>
> > 4))
> > +                {
> > 
> > +                if
> > (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> > +               
> >   return -1;
> > +                }
> > 
> > +              break;
> > +          }    
> >   
> > +      }     
> >    
> >        break;
> > -
> >        /* string ops */
> >        /* movsS */
> >      case 0xa4:
> > @@ -4777,10 +5106,17 @@
> >        /* fwait */
> >        /* XXX */
> >      case 0x9b:
> > -      printf_unfiltered (_("Process record
> > doesn't support instruction "
> > -           
> >    "fwait.\n"));
> > -      ir.addr -= 1;
> > -      goto no_support;
> > +      if (target_read_memory (ir.addr,
> > &tmpu8, 1))
> > +        {
> > +          if (record_debug)
> > +           
> > printf_unfiltered (_("Process record: error reading
> memory
> > at "
> > +               
> >                
> >                
> >         "addr 0x%s len = 1.\n"),
> > +               
> >          
> >    paddress (gdbarch, ir.addr));
> > 
> > msnyder: indentation
> >          
> >    printf_unfiltered (_("Process record:
> > error reading memory at "
> >                
> >                
> >   "addr 0x%s len = 1.\n"),
> >                
> >                
> > paddress (gdbarch, ir.addr));
> > 
> > +          return -1;
> > +        }
> > +      opcode = (uint32_t) tmpu8;
> > +      ir.addr++;
> > +      goto reswitch; 
> >    
> >        break;
> >  
> >        /* int3 */
> > 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

* final   i386.floating.record.patch
  2009-07-27  1:09 i386.record.floating.point.patch : with more testing and assurity Michael Snyder
@ 2009-07-29 18:30 ` paawan oza
  2009-07-29 22:01   ` Michael Snyder
  0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-29 18:30 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches


Hi All,

Now the format is modified, and I am submitting the patch, I hope this meets the expectations.
thank you all for your review comments specially Micahel and Hui.
please find the patch as follows. 

**********
ChangeLog
**********
Current: gdb-6.8.50.20090729
2009-07-29  Oza  <paawan1982@yahoo.com>

        * i386-tdep.c: Support for floating point recording.

******
README
******
Patch description:

-> Provides floating point support for i386  (reversible debugging:record-replay)
-> previously gdb was not recording floating point registers, now all the floating point registers which are likely to be changed by floating   point instructions, are recorded and replayed.
-> the patch intends to provide the full support for all i386 floating point instructions.


*****
patch
*****

diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c	2009-07-29 19:48:51.000000000 -0400
+++ gdb.new/i386-tdep.c	2009-07-29 19:51:08.000000000 -0400
@@ -3139,6 +3139,66 @@
   return 0;
 }
 
+
+/* Defines contents to record.  */
+#define I386_SAVE_FPU_REGS              0xfffd
+#define I386_SAVE_FPU_ENV               0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK     0xffff
+
+/* Record the value of floating point registers which will be changed by the
+   current instruction to "record_arch_list".  Return -1 if something is wrong.  
+*/  
+
+static int i386_record_floats (struct gdbarch *gdbarch,  
+                               struct i386_record_s *ir,  
+                               uint32_t iregnum)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int i;
+
+  /* Oza: Because of floating point insn push/pop of fpu stack is going to 
+     happen.  Currently we store st0-st7 registers, but we need not store all 
+     registers all the time, in future we use ftag register and record only 
+     those who are not marked as an empty.  */
+
+  if (I386_SAVE_FPU_REGS == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+        {
+          if (record_arch_list_add_reg (ir->regcache, i))
+            return -1;
+        }
+    }
+  else if (I386_SAVE_FPU_ENV == iregnum)
+    {
+      for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+	{
+	  if (record_arch_list_add_reg (ir->regcache, i))
+	    return -1;
+	}
+    }
+  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+    {
+      for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+      {
+        if (record_arch_list_add_reg (ir->regcache, i))
+          return -1;
+      }
+    }
+  else if ((iregnum >= I387_ST0_REGNUM (tdep)) && 
+           (iregnum <= I387_FOP_REGNUM (tdep)))
+    {
+      if (record_arch_list_add_reg (ir->regcache,iregnum))
+        return -1;
+    }
+  else
+    {
+      /* Parameter error.  */
+      return -1;
+    }
+  return 0;
+}
+
 /* Parse the current instruction and record the values of the registers and
    memory that will be changed in current instruction to "record_arch_list".
    Return -1 if something wrong. */
@@ -3153,6 +3213,7 @@
   uint32_t tmpu32;
   uint32_t opcode;
   struct i386_record_s ir;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   memset (&ir, 0, sizeof (struct i386_record_s));
   ir.regcache = regcache;
@@ -4188,8 +4249,7 @@
 	}
       break;
 
-      /* floats */
-      /* It just record the memory change of instrcution. */
+    /* Floats.  */
     case 0xd8:
     case 0xd9:
     case 0xda:
@@ -4203,45 +4263,56 @@
       ir.reg |= ((opcode & 7) << 3);
       if (ir.mod != 3)
 	{
-	  /* memory */
+	  /* Memory.  */
 	  uint32_t addr;
 
 	  if (i386_record_lea_modrm_addr (&ir, &addr))
 	    return -1;
 	  switch (ir.reg)
 	    {
-	    case 0x00:
-	    case 0x01:
 	    case 0x02:
+            case 0x12:
+            case 0x22:
+            case 0x32:
+              /* For fcom, ficom nothing to do.  */
+              break;
 	    case 0x03:
+            case 0x13:
+            case 0x23:
+            case 0x33:
+              /* For fcomp, ficomp pop FPU stack, store all.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
+              break;
+            case 0x00:
+            case 0x01:
 	    case 0x04:
 	    case 0x05:
 	    case 0x06:
 	    case 0x07:
 	    case 0x10:
 	    case 0x11:
-	    case 0x12:
-	    case 0x13:
 	    case 0x14:
 	    case 0x15:
 	    case 0x16:
 	    case 0x17:
 	    case 0x20:
 	    case 0x21:
-	    case 0x22:
-	    case 0x23:
 	    case 0x24:
 	    case 0x25:
 	    case 0x26:
 	    case 0x27:
 	    case 0x30:
 	    case 0x31:
-	    case 0x32:
-	    case 0x33:
 	    case 0x34:
 	    case 0x35:
 	    case 0x36:
 	    case 0x37:
+              /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
+                 fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension
+                 of code,  always affects st(0) register.  */
+              if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+                return -1;
 	      break;
 	    case 0x08:
 	    case 0x0a:
@@ -4250,6 +4321,7 @@
 	    case 0x19:
 	    case 0x1a:
 	    case 0x1b:
+            case 0x1d: 
 	    case 0x28:
 	    case 0x29:
 	    case 0x2a:
@@ -4258,9 +4330,14 @@
 	    case 0x39:
 	    case 0x3a:
 	    case 0x3b:
+            case 0x3c: 
+            case 0x3d: 
 	      switch (ir.reg & 7)
 		{
 		case 0:
+		  /* Handling fld, fild.  */
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
 		  break;
 		case 1:
 		  switch (ir.reg >> 4)
@@ -4274,6 +4351,7 @@
 			return -1;
 		      break;
 		    case 3:
+		      break;
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4284,15 +4362,49 @@
 		  switch (ir.reg >> 4)
 		    {
 		    case 0:
+		      if (record_arch_list_add_mem (addr, 4))
+			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m32fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      break;
 		    case 1:
 		      if (record_arch_list_add_mem (addr, 4))
 			return -1;
+		      if ((3 == (ir.reg & 7))
+			  || (5 == (ir.reg & 7))
+			  || (7 == (ir.reg & 7)))
+			{
+			  /* For fstp insn.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 2:
 		      if (record_arch_list_add_mem (addr, 8))
 			return -1;
+		      if (3 == (ir.reg & 7))
+			{
+			  /* For fstp m64fp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
 		      break;
 		    case 3:
+		      if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+			{
+			  /* For fistp, fbld, fild, fbstp.  */
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I386_SAVE_FPU_REGS))
+			    return -1;
+			}
+		      /* Fall through */  
 		    default:
 		      if (record_arch_list_add_mem (addr, 2))
 			return -1;
@@ -4302,11 +4414,21 @@
 		}
 	      break;
 	    case 0x0c:
+              /* Insn fldenv.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
+              break;
 	    case 0x0d:
-	    case 0x1d:
+              /* Insn fldcw.  */
+              if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+                return -1;
+              break;
 	    case 0x2c:
-	    case 0x3c:
-	    case 0x3d:
+              /* Insn frstor.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x0e:
 	      if (ir.dflag)
@@ -4329,6 +4451,9 @@
 	    case 0x3e:
 	      if (record_arch_list_add_mem (addr, 10))
 		return -1;
+              /* Insn fstp, fbstp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    case 0x2e:
 	      if (ir.dflag)
@@ -4345,10 +4470,17 @@
 		}
 	      if (record_arch_list_add_mem (addr, 80))
 		return -1;
+              /* Insn fsave.  */
+              if (i386_record_floats (gdbarch, &ir, 
+                                      I386_SAVE_FPU_ENV_REG_STACK))
+                return -1;
 	      break;
 	    case 0x3f:
 	      if (record_arch_list_add_mem (addr, 8))
 		return -1;
+              /* Ins fistp.  */
+              if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+                return -1;
 	      break;
 	    default:
 	      ir.addr -= 2;
@@ -4357,8 +4489,211 @@
 	      break;
 	    }
 	}
+      /* Opcode is an extension of modR/M byte.  */     
+      else
+        { 
+	  switch (opcode)
+	    {
+	    case 0xd8:
+	      if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+		return -1;	
+	      break;
+	    case 0xd9:    
+	      if (0x0c == (ir.modrm >> 4))
+		{
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;	
+		    }
+                  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;	
+		      /* If only st(0) is changing, then we have already 
+			 recorded.  */
+		      if ((ir.modrm & 0x0f) - 0x08)
+			{
+			  if (i386_record_floats (gdbarch, &ir, 
+						  I387_ST0_REGNUM (tdep) +
+						  ((ir.modrm & 0x0f) - 0x08)))
+			    return -1;	                      
+			}
+		    }
+		}
+              else
+                {
+		  switch (ir.modrm)
+		    {
+		    case 0xe0:
+		    case 0xe1:
+		    case 0xf0:
+		    case 0xf5:
+		    case 0xf8:
+		    case 0xfa:
+		    case 0xfc:
+		    case 0xfe:
+		    case 0xff:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      break;
+		    case 0xf1:
+		    case 0xf2:
+		    case 0xf3:
+		    case 0xf4:
+		    case 0xf6:
+		    case 0xf7:
+		    case 0xe8:
+		    case 0xe9:
+		    case 0xea:
+		    case 0xeb:
+		    case 0xec:
+		    case 0xed:
+		    case 0xee:
+		    case 0xf9:
+		    case 0xfb:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+			return -1;
+		      break;
+		    case 0xfd:
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep)))
+			return -1;
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 1))
+			return -1;
+		      break;
+		    }
+		}
+              break;
+            case 0xda:
+              if (0xe9 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) + 
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdb:
+              if (0xe3 == ir.modrm)
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
+		    return -1;
+                }
+              else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, 
+					  I387_ST0_REGNUM (tdep)))
+		    return -1;
+		  if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else if ((ir.modrm & 0x0f) - 0x08)
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+              break;
+            case 0xdc:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0d == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4))
+                {
+		  if ((ir.modrm & 0x0f) <= 7)
+		    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+		    }
+		  else
+		    {
+		      if (i386_record_floats (gdbarch, &ir,
+					      I387_ST0_REGNUM (tdep) +
+					      ((ir.modrm & 0x0f) - 0x08)))
+			return -1;
+		    }
+                }
+	      break;
+            case 0xdd:
+              if (0x0c == ir.modrm >> 4)
+                {
+                  if (i386_record_floats (gdbarch, &ir, 
+                                          I387_FTAG_REGNUM (tdep)))
+                    return -1;
+                }
+              else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+                  if ((ir.modrm & 0x0f) <= 7)
+                    {
+		      if (i386_record_floats (gdbarch, &ir, 
+					      I387_ST0_REGNUM (tdep) +
+					      (ir.modrm & 0x0f)))
+			return -1;
+                    }
+                  else
+                    {
+                      if (i386_record_floats (gdbarch, &ir, 
+					      I386_SAVE_FPU_REGS))
+                        return -1;
+                    }
+                }
+              break;
+            case 0xde:
+              if ((0x0c == ir.modrm >> 4)
+		  || (0x0e == ir.modrm >> 4)
+		  || (0x0f == ir.modrm >> 4)
+		  || (0xd9 == ir.modrm))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;	 
+                }
+              break;
+            case 0xdf:
+              if (0xe0 == ir.modrm)
+                {
+		  if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+		    return -1;
+                }
+              else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+                {
+		  if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+		    return -1;
+                }
+              break;
+	    }
+	}
       break;
-
       /* string ops */
       /* movsS */
     case 0xa4:
@@ -4775,12 +5110,18 @@
       break;
 
       /* fwait */
-      /* XXX */
     case 0x9b:
-      printf_unfiltered (_("Process record doesn't support instruction "
-			   "fwait.\n"));
-      ir.addr -= 1;
-      goto no_support;
+      if (target_read_memory (ir.addr, &tmpu8, 1))
+        {
+          if (record_debug)
+            printf_unfiltered (_("Process record: error reading memory at "
+				 "addr 0x%s len = 1.\n"),
+			       paddress (gdbarch, ir.addr));
+          return -1;
+        }
+      opcode = (uint32_t) tmpu8;
+      ir.addr++;
+      goto reswitch;     
       break;
 
       /* int3 */


Regards,
Oza.




--- On Mon, 7/27/09, Michael Snyder <msnyder@vmware.com> wrote:

> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Hui Zhu" <teawater@gmail.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Monday, July 27, 2009, 12:34 AM
> paawan oza wrote:
> 
> > (please try take difference with attached files and
> see the 'diff' result, it is strange, if you take the patch
> on windows it gets even more worse with formatting)
> 
> OK, I've done as you suggested.  Here are my comments
> (search for "msnyder):
> 
> 
> -----Inline Attachment Follows-----
> 
> 
> --- i386-tdep.0726.c    2009-07-26
> 10:55:37.000013000 -0700
> +++ i386-tdep.c    2009-07-26
> 11:00:19.001044000 -0700
> @@ -3139,6 +3139,66 @@
>    return 0;
>  }
>  
> +
> +/* Defines contents to record.  */
> +#define I386_SAVE_FPU_REGS       
>       0xfffd
> +#define I386_SAVE_FPU_ENV       
>        0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK 
>    0xffff
> +
> +/* Record the value of floating point registers which will
> be changed by the
> +   current instruction to
> "record_arch_list".  Return -1 if something is
> wrong.  
> +*/  
> +
> +static int i386_record_floats (struct gdbarch
> *gdbarch,  
> +               
>            
>    struct i386_record_s *ir,  
> +               
>            
>    uint32_t iregnum)
> +{
> +  struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
> +  int i;
> +
> +  /* Oza:Because of floating point insn push/pop of
> fpu stack is going to 
> 
> msnyder: "Oza: Because"
> 
> +     happen.  Currently we store
> st0-st7 registers, but we need not store all 
> +     registers all the time, in future
> we use ftag register and record only 
> +     those who are not marked as an
> empty.  
> +   */
> +  if (I386_SAVE_FPU_REGS == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep);i
> <= I387_ST0_REGNUM (tdep) + 7;i++)
> 
> msynder:
>        for (i = I387_ST0_REGNUM
> (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
> 
> +        {
> +          if
> (record_arch_list_add_reg (ir->regcache, i))
> +            return -1;
> +        }
> +    }
> +  else if (I386_SAVE_FPU_ENV == iregnum)
> +    {
> +      for (i = I387_FCTRL_REGNUM (tdep);i
> <= I387_FOP_REGNUM (tdep);i++)
> 
> msnyder:
>        for (i = I387_FCTRL_REGNUM
> (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> 
> +      {
> 
> msnyder: indent { to the right by two spaces after "for".
> 
> +        if (record_arch_list_add_reg
> (ir->regcache, i))
> +          return -1;
> +      }
> +    }
> +  else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> +    {
> +      for (i = I387_ST0_REGNUM (tdep);i
> <= I387_FOP_REGNUM (tdep);i++)
> 
> msnyder:
>        for (i = I387_ST0_REGNUM
> (tdep); i <= I387_FOP_REGNUM (tdep); i++)
> 
> +      {
> +        if (record_arch_list_add_reg
> (ir->regcache, i))
> +          return -1;   
> 
> +      }
> +    }
> +  else if ((iregnum >= I387_ST0_REGNUM (tdep))
> && 
> +           (iregnum
> <= I387_FOP_REGNUM (tdep)))
> +    {
> +      if (record_arch_list_add_reg
> (ir->regcache,iregnum))
> +        return -1;
> +    }
> +  else
> +    {
> +      /* Parameter error.  */
> +      return -1;
> +    } 
> +  return 0;
> +}
> +
>  /* Parse the current instruction and record the values of
> the registers and
>     memory that will be changed in current
> instruction to "record_arch_list".
>     Return -1 if something wrong. */
> @@ -3153,6 +3213,7 @@
>    uint32_t tmpu32;
>    uint32_t opcode;
>    struct i386_record_s ir;
> +  struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
>  
>    memset (&ir, 0, sizeof (struct
> i386_record_s));
>    ir.regcache = regcache;
> @@ -4188,8 +4249,7 @@
>      }
>        break;
>  
> -      /* floats */
> -      /* It just record the memory change
> of instrcution. */
> +    /* Floats.  */
>      case 0xd8:
>      case 0xd9:
>      case 0xda:
> @@ -4203,45 +4263,56 @@
>        ir.reg |= ((opcode & 7)
> << 3);
>        if (ir.mod != 3)
>      {
> -      /* memory */
> +        /* Memory.  */
>        uint32_t addr;
>  
>        if (i386_record_lea_modrm_addr
> (&ir, &addr))
>          return -1;
>        switch (ir.reg)
>          {
> -        case 0x00:
> -        case 0x01:
>          case 0x02:
> +            case 0x12:
> +            case 0x22:
> +            case 0x32:
> +              /* For
> fcom, ficom nothing to do.  */
> +              break;
>          case 0x03:
> +            case 0x13:
> +            case 0x23:
> +            case 0x33:
> +              /* For
> fcomp, ficomp pop FPU stack, store all.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;
> +              break;
> +            case 0x00:
> +            case 0x01:
>          case 0x04:
>          case 0x05:
>          case 0x06:
>          case 0x07:
>          case 0x10:
>          case 0x11:
> -        case 0x12:
> -        case 0x13:
>          case 0x14:
>          case 0x15:
>          case 0x16:
>          case 0x17:
>          case 0x20:
>          case 0x21:
> -        case 0x22:
> -        case 0x23:
>          case 0x24:
>          case 0x25:
>          case 0x26:
>          case 0x27:
>          case 0x30:
>          case 0x31:
> -        case 0x32:
> -        case 0x33:
>          case 0x34:
>          case 0x35:
>          case 0x36:
>          case 0x37:
> +              /* For
> fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul, 
> +             
>    fisub, fisubr, fidiv, fidivr, modR/M.reg
> is an extension of code, 
> +             
>    always affects st(0) register.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +               
> return -1;
>            break;
>          case 0x08:
>          case 0x0a:
> @@ -4250,6 +4321,7 @@
>          case 0x19:
>          case 0x1a:
>          case 0x1b:
> +            case 0x1d: 
>          case 0x28:
>          case 0x29:
>          case 0x2a:
> @@ -4258,9 +4330,14 @@
>          case 0x39:
>          case 0x3a:
>          case 0x3b:
> +            case 0x3c: 
> +            case 0x3d: 
>            switch (ir.reg
> & 7)
>          {
>          case 0:
> +               
>     /* Handling fld, fild.  */
> +               
>     if (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +               
>       return -1;    
> 
> msnyder: indented too far (two spaces extra):
>                
>    /* Handling fld, fild.  */
>                
>    if (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
>                
>      return -1;    
> 
> 
> 
>            break;
>          case 1:
>            switch
> (ir.reg >> 4)
> @@ -4274,6 +4351,7 @@
>             
> return -1;
>               
> break;
>              case
> 3:
> +               
>         break;
> 
> msnyder: indented too far:
>                
>        break;
> 
>             
> default:
>               
> if (record_arch_list_add_mem (addr, 2))
>             
> return -1;
> @@ -4284,15 +4362,49 @@
>            switch
> (ir.reg >> 4)
>              {
>              case
> 0:
> +               
>           if
> (record_arch_list_add_mem (addr, 4))
> +               
>             return -1;
> +               
>           if (3 == (ir.reg &
> 7))
> +               
>             {
> +               
>             /* For fstp
> m32fp.  */
> +               
>             if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>                
>     I386_SAVE_FPU_REGS))
> +               
>               return
> -1;               
>         
> +               
>             } 
> +               
>           break;
> 
> msnyder: indented four extra spaces too far.
> 
> 
> 
>              case
> 1:
>               
> if (record_arch_list_add_mem (addr, 4))
>             
> return -1;
> +               
>         if ((3 == (ir.reg &
> 7))  \
> +               
>            || (5 ==
> (ir.reg & 7))  \
> +               
>            || (7 ==
> (ir.reg & 7)))
> 
> msnyder: remove '\' from end of lines:
> 
>                
>         if ((3 == (ir.reg & 7))
>                
>             || (5 == (ir.reg
> & 7))
>                
>             || (7 == (ir.reg
> & 7)))
> 
> 
> 
> 
> +               
>           {
> +               
>           /* For fstp insn. 
> */
> +               
>             if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>                
>     I386_SAVE_FPU_REGS))
> +               
>               return
> -1;               
>         
> +               
>           } 
>               
> break;
>              case
> 2:
>               
> if (record_arch_list_add_mem (addr, 8))
>             
> return -1;
> +               
>           if (3 == (ir.reg &
> 7))
> +               
>             {
> +               
>             /* For fstp
> m64fp.  */
> +               
>             if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>                
>     I386_SAVE_FPU_REGS))
> +               
>               return
> -1;               
>         
> +               
>             } 
> 
> msnyder: indented too far.
> 
>               
> break;
>              case
> 3:
> +               
>           if ((3 <= (ir.reg
> & 7)) && (6 <= (ir.reg & 7)))
> +               
>             {
> +               
>             /* For fistp,
> fbld, fild, fbstp.  */
> +               
>             if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>                
>     I386_SAVE_FPU_REGS))
> +               
>               return
> -1;               
>         
> +               
>             }  
> +               
>         /*Fall through */  
> 
> msnyder: indented too far.
> 
>             
> default:
>               
> if (record_arch_list_add_mem (addr, 2))
>             
> return -1;
> @@ -4302,11 +4414,21 @@
>          }
>            break;
>          case 0x0c:
> +              /* Insn
> fldenv.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;  
> +              break;
>          case 0x0d:
> -        case 0x1d:
> +              /* Insn
> fldcw.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM
> (tdep)))
> +               
> return -1;  
> +              break;
>          case 0x2c:
> -        case 0x3c:
> -        case 0x3d:
> +              /* Insn
> frstor.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;  
>            break;
>          case 0x0e:
>            if (ir.dflag)
> @@ -4329,6 +4451,9 @@
>          case 0x3e:
>            if
> (record_arch_list_add_mem (addr, 10))
>          return -1;
> +              /* Insn
> fstp, fbstp.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;             
>                
>     
>            break;
>          case 0x2e:
>            if (ir.dflag)
> @@ -4345,10 +4470,17 @@
>          }
>            if
> (record_arch_list_add_mem (addr, 80))
>          return -1;
> +              /* Insn
> fsave.  */
> +              if
> (i386_record_floats (gdbarch, &ir, 
> +               
>                
>       I386_SAVE_FPU_ENV_REG_STACK))
> +               
> return -1;   
>            break;
>          case 0x3f:
>            if
> (record_arch_list_add_mem (addr, 8))
>          return -1;
> +              /* Ins
> fistp.  */
> +              if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
> return -1;   
>            break;
>          default:
>            ir.addr -= 2;
> @@ -4357,8 +4489,205 @@
>            break;
>          }
>      }
> +        /* Opcode is an extension of
> modR/M byte.  */     
> +        else
> 
> msnyder:  above, indentation level minus two after }
>       /* Opcode is an extension of modR/M
> byte.  */     
>       else
> 
> +        { 
> +        switch (opcode)
> 
> msnyder: above, indentation level plus two after {
>            switch
> (opcode)
> 
> And then everything below this point needs to be
> re-indented to the right.
> 
> 
> +          {
> +          case 0xd8:
> +            if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +              return
> -1;    
> +            break;
> +          case 0xd9:   
> 
> +            if (0x0c ==
> (ir.modrm >> 4))
> +              {
> +                if
> ((ir.modrm & 0x0f) <= 7)
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +               
>     return -1;    
> 
> msnyder: missing a right-indent.
> 
> +               
>   }
> +               
>   else
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_ST0_REGNUM (tdep)))
> 
> msnyder: missing a right-indent.
> 
> +               
>     return -1;    
> +               
>   /* If only st(0) is changing, then we have already
> recorded.  */
> +               
>   if ((ir.modrm & 0x0f) - 0x08)
> +               
>     {
> +               
>     if (i386_record_floats (gdbarch, &ir, 
> 
> msnyder: missing a right-indent.
> 
> +               
>                
>             I387_ST0_REGNUM
> (tdep) + \
> 
> msnyder: no \ at end of line.
> 
>                
>                
>          
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>             ((ir.modrm &
> 0x0f) - 0x08)))
> +               
>       return -1;     
>                
>     
> +               
>     } 
> +               
>   }  
> +              }
> +              else
> +                {
> 
> msnyder: indentation.
> 
> +               
> switch(ir.modrm)
> 
> msnyder: "switch ("
> 
> +               
>   {
> +               
>   case 0xe0:
> +               
>   case 0xe1:
> +               
>   case 0xf0:
> +               
>   case 0xf5:
> +               
>   case 0xf8:
> +               
>   case 0xfa:
> +               
>   case 0xfc:
> +               
>   case 0xfe:
> +               
>   case 0xff:
> +               
>     if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>             I387_ST0_REGNUM
> (tdep)))
> +               
>       return -1;
> +               
>     break;       
>    
> +               
>   case 0xf1:  
> +               
>   case 0xf2:  
> +               
>   case 0xf3:  
> +               
>   case 0xf4:
> +               
>   case 0xf6: 
> +               
>   case 0xf7:    
> +               
>   case 0xe8:  
> +               
>   case 0xe9:  
> +               
>   case 0xea:  
> +               
>   case 0xeb:
> +               
>   case 0xec:        
> +               
>   case 0xed:    
> +               
>   case 0xee:   
> +               
>   case 0xf9:     
> +               
>   case 0xfb:
> +               
>     if (i386_record_floats (gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +               
>       return -1;    
> +               
>     break;
> +               
>   case 0xfd: 
> +               
>     if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>             I387_ST0_REGNUM
> (tdep)))
> +               
>       return -1;
> +               
>     if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>             I387_ST0_REGNUM
> (tdep) + 1))
> +               
>       return -1;
> +               
>     break;
> +               
>   } 
> +              }
> +              break;
> +            case 0xda:
> +              if (0xe9
> == ir.modrm)
> +                {
> +                if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
>   return -1;           
>         
> 
> msnyder: indentation after {
> 
> +                }
> +              else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> +                {
> +                if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> 
> msnyder: indentation after {
> 
> +               
>   return -1;         
>           
> +                if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> 
> msnyder: indentation after {
> 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>           (ir.modrm & 0x0f)))
> +               
>     return -1;       
>                
>   
> +               
>   }
> +               
> else if ((ir.modrm & 0x0f) - 0x08)
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> \
> 
> msnyder: no \ at end of line.
>                
>                
>        
>    I387_ST0_REGNUM (tdep) +
> 
> 
> +               
>                
>           ((ir.modrm & 0x0f) -
> 0x08)))
> +               
>     return -1;
> +               
>   }
> +               
> }  
> +              break; 
> +            case 0xdb:
> +              if (0xe3
> == ir.modrm)
> +                {
> +                if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
> 
> msnyder: indentation after {
> 
> +               
>   return -1;           
>         
> +                }
> +              else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> +                {
> +                if
> (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> 
> msnyder: indentation after {
> 
> +               
>   return -1;         
>           
> +                if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> 
> msnyder: indentation after {
> 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> \
> 
> msnyder: no \ at end of line.
>                
>                
>        
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>           (ir.modrm & 0x0f)))
> +               
>     return -1;       
>                
>   
> +               
>   }
> +               
> else if ((ir.modrm & 0x0f) - 0x08)
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> 
> msnyder: indentation after {
> 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> \
> 
> msnyder: no \ at end of line.
>                
>                
>        
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>           ((ir.modrm & 0x0f) -
> 0x08)))
> +               
>     return -1;
> +               
>   }
> +               
> }  
> +              break;
> +            case 0xdc:
> +              if ((0x0c
> == ir.modrm >> 4)    \
> +             
>    || (0x0d == ir.modrm >> 4)  \
> +             
>    || (0x0f == ir.modrm >> 4))
> 
> msnyder: no \ at end of line.
>            
>    if ((0x0c == ir.modrm >> 4)
>                
>    || (0x0d == ir.modrm >> 4)
>                
>    || (0x0f == ir.modrm >> 4))
> 
> +                {
> +                if
> ((ir.modrm & 0x0f) <= 7)
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> \
> 
> msnyder: no \ at end of line.
>                
>                
>        
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>           (ir.modrm & 0x0f)))
> +               
>     return -1;       
>                
>   
> +               
>   }
> +               
> else
> +               
>   {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_ST0_REGNUM (tdep) +
> \
> 
> msnyder: no \ at end of line.
>                
>                
>        
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>           ((ir.modrm & 0x0f) -
> 0x08)))
> +               
>     return -1;
> +               
>   }
> +               
> }  
> +           
>    break;
> +            case 0xdd: 
>            
> +              if (0x0c
> == ir.modrm >> 4)
> +                {
> +               
>   if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>           I387_FTAG_REGNUM
> (tdep)))
> +               
>     return -1;
> +                }
> +              else if
> ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> +                {
> 
> +               
>   if ((ir.modrm & 0x0f) <= 7)
> +               
>     {
> +               
>     if (i386_record_floats (gdbarch, &ir, 
> +               
>                
>             I387_ST0_REGNUM
> (tdep) + \
> 
> msnyder: no \ at end of line.
>                
>                
>          
>    I387_ST0_REGNUM (tdep) +
> 
> +               
>                
>             (ir.modrm &
> 0x0f)))
> +               
>       return
> -1;     
> +               
>     }
> +               
>   else
> +               
>     {
> +               
>       if (i386_record_floats (gdbarch,
> &ir, I386_SAVE_FPU_REGS))
> +               
>         return -1;
> +               
>     }
> +               
> }            
> +              break;
> +            case 0xde:
> +              if ((0x0c
> == ir.modrm >> 4)  \
> +             
>    || (0x0e == ir.modrm >> 4)  \
> +             
>    || (0x0f == ir.modrm >> 4)  \
> +             
>    || (0xd9 == ir.modrm))
> 
> msnyder: no \ at end of line.
>            
>    if ((0x0c == ir.modrm >> 4)
>                
>    || (0x0e == ir.modrm >> 4)
>                
>    || (0x0f == ir.modrm >> 4)
>                
>    || (0xd9 == ir.modrm))
> 
> 
> +               
> {               
>    
> +                if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
>   return -1;     
> +               
> }   
> +              break;
> +            case 0xdf:
> +              if (0xe0
> == ir.modrm)
> +                {
> +                if
> (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> +               
>   return -1;
> +                }
> +              else if
> ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> +                {
> 
> +                if
> (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
> +               
>   return -1;
> +                }
> 
> +              break;
> +          }    
>   
> +      }     
>    
>        break;
> -
>        /* string ops */
>        /* movsS */
>      case 0xa4:
> @@ -4777,10 +5106,17 @@
>        /* fwait */
>        /* XXX */
>      case 0x9b:
> -      printf_unfiltered (_("Process record
> doesn't support instruction "
> -           
>    "fwait.\n"));
> -      ir.addr -= 1;
> -      goto no_support;
> +      if (target_read_memory (ir.addr,
> &tmpu8, 1))
> +        {
> +          if (record_debug)
> +           
> printf_unfiltered (_("Process record: error reading memory
> at "
> +               
>                
>                
>         "addr 0x%s len = 1.\n"),
> +               
>          
>    paddress (gdbarch, ir.addr));
> 
> msnyder: indentation
>          
>    printf_unfiltered (_("Process record:
> error reading memory at "
>                
>                
>   "addr 0x%s len = 1.\n"),
>                
>                
> paddress (gdbarch, ir.addr));
> 
> +          return -1;
> +        }
> +      opcode = (uint32_t) tmpu8;
> +      ir.addr++;
> +      goto reswitch; 
>    
>        break;
>  
>        /* int3 */
> 




^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2009-12-10  7:55 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-03 14:56 final i386.floating.record.patch paawan oza
2009-08-03 20:04 ` Michael Snyder
2009-08-04  3:20 ` Hui Zhu
2009-08-04 13:03   ` paawan oza
  -- strict thread matches above, loose matches on Subject: below --
2009-08-21 16:59 paawan oza
2009-08-23  1:32 ` Hui Zhu
2009-08-23  3:00   ` Michael Snyder
2009-08-23  9:04     ` paawan oza
2009-08-23  9:29     ` paawan oza
2009-09-09  0:19 ` Michael Snyder
2009-09-10  1:13   ` paawan oza
2009-09-26  9:33   ` paawan oza
2009-12-10  7:55 ` Hui Zhu
2009-08-18 15:22 paawan oza
2009-08-19  2:17 ` Hui Zhu
2009-08-19  2:44   ` Hui Zhu
2009-08-07  7:25 paawan oza
2009-08-07 15:50 ` Hui Zhu
2009-08-16 21:41 ` Michael Snyder
2009-08-17  9:17   ` Hui Zhu
2009-08-17 16:16     ` paawan oza
2009-08-04 13:06 paawan oza
2009-08-04 13:58 ` Hui Zhu
2009-08-04 14:18   ` paawan oza
2009-08-04 14:26   ` paawan oza
2009-08-04 14:43     ` Hui Zhu
2009-08-04 17:59       ` paawan oza
2009-08-05  1:29         ` Hui Zhu
2009-08-05  1:34         ` Michael Snyder
2009-08-05 13:48           ` paawan oza
2009-07-29 18:34 paawan oza
2009-07-30  6:24 ` Michael Snyder
2009-07-30 18:09   ` paawan oza
2009-08-03 14:59   ` paawan oza
2009-08-03 20:07     ` Michael Snyder
2009-07-27  1:09 i386.record.floating.point.patch : with more testing and assurity Michael Snyder
2009-07-29 18:30 ` final i386.floating.record.patch paawan oza
2009-07-29 22:01   ` Michael Snyder
2009-07-30  0:44     ` Michael Snyder
2009-07-30 18:00       ` paawan oza
2009-07-30 21:13         ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox