Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/prec] Make i386 handle segment register better
@ 2009-08-29 16:12 Hui Zhu
  2009-08-29 21:34 ` Michael Snyder
  0 siblings, 1 reply; 10+ messages in thread
From: Hui Zhu @ 2009-08-29 16:12 UTC (permalink / raw)
  To: gdb-patches ml; +Cc: Michael Snyder

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

Hi guys,

In prec-fix-x86-strinsn.txt patch, I add code the compare the ES and
DS to make sure if es if same with ds or not.
I think it works not bad, so I make a patch to check other segment
regiser like it.

Please help me with it.

Thanks,
Hui

2009-08-29  Hui Zhu  <teawater@gmail.com>

	* i386-tdep.c (i386_record_check_override): New function.
	(i386_record_lea_modrm): Call i386_record_check_override.
	(i386_process_record): Ditto.

---
 i386-tdep.c |   37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

--- a/i386-tdep.c
+++ b/i386-tdep.c
@@ -3147,6 +3147,26 @@ no_rm:
   return 0;
 }

+static int
+i386_record_check_override (struct i386_record_s *irp)
+{
+  if (irp->override >= 0 && irp->override != X86_RECORD_DS_REGNUM)
+    {
+      ULONGEST tmp, ds;
+
+      regcache_raw_read_unsigned (irp->regcache,
+                                  irp->regmap[irp->override],
+                                  &tmp);
+      regcache_raw_read_unsigned (irp->regcache,
+                                  irp->regmap[X86_RECORD_DS_REGNUM],
+                                  &ds);
+      if (tmp != ds)
+        return 1;
+    }
+
+  return 0;
+}
+
 /* Record the value of the memory that willbe changed in current instruction
    to "record_arch_list".
    Return -1 if something wrong. */
@@ -3157,7 +3177,7 @@ i386_record_lea_modrm (struct i386_recor
   struct gdbarch *gdbarch = irp->gdbarch;
   uint64_t addr;

-  if (irp->override >= 0)
+  if (i386_record_check_override (irp))
     {
       if (record_debug)
 	printf_unfiltered (_("Process record ignores the memory change "
@@ -4039,7 +4059,7 @@ reswitch:
       /* mov EAX */
     case 0xa2:
     case 0xa3:
-      if (ir.override >= 0)
+      if (i386_record_check_override (&ir))
         {
 	  if (record_debug)
 	    printf_unfiltered (_("Process record ignores the memory change "
@@ -4458,13 +4478,8 @@ reswitch:
                                       ir.regmap[X86_RECORD_REDI_REGNUM],
                                       &tmpulongest);

-          regcache_raw_read_unsigned (ir.regcache,
-                                      ir.regmap[X86_RECORD_ES_REGNUM],
-                                      &es);
-          regcache_raw_read_unsigned (ir.regcache,
-                                      ir.regmap[X86_RECORD_DS_REGNUM],
-                                      &ds);
-          if (ir.aflag && (es != ds))
+          ir.override = X86_RECORD_ES_REGNUM;
+          if (ir.aflag && i386_record_check_override (&ir))
             {
               /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
               if (record_debug)
@@ -5086,7 +5101,7 @@ reswitch:
 		opcode = opcode << 8 | ir.modrm;
 		goto no_support;
 	      }
-	    if (ir.override >= 0)
+	    if (i386_record_check_override (&ir))
 	      {
 		if (record_debug)
 		  printf_unfiltered (_("Process record ignores the memory "
@@ -5138,7 +5153,7 @@ reswitch:
 	  else
 	    {
 	      /* sidt */
-	      if (ir.override >= 0)
+	      if (i386_record_check_override (&ir))
 		{
 		  if (record_debug)
 		    printf_unfiltered (_("Process record ignores the memory "

[-- Attachment #2: prec-i386-override.txt --]
[-- Type: text/plain, Size: 2729 bytes --]

---
 i386-tdep.c |   37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

--- a/i386-tdep.c
+++ b/i386-tdep.c
@@ -3147,6 +3147,26 @@ no_rm:
   return 0;
 }
 
+static int
+i386_record_check_override (struct i386_record_s *irp)
+{
+  if (irp->override >= 0 && irp->override != X86_RECORD_DS_REGNUM)
+    {
+      ULONGEST tmp, ds;
+
+      regcache_raw_read_unsigned (irp->regcache,
+                                  irp->regmap[irp->override],
+                                  &tmp);
+      regcache_raw_read_unsigned (irp->regcache,
+                                  irp->regmap[X86_RECORD_DS_REGNUM],
+                                  &ds);
+      if (tmp != ds)
+        return 1;
+    }
+
+  return 0;
+}
+
 /* Record the value of the memory that willbe changed in current instruction
    to "record_arch_list".
    Return -1 if something wrong. */
@@ -3157,7 +3177,7 @@ i386_record_lea_modrm (struct i386_recor
   struct gdbarch *gdbarch = irp->gdbarch;
   uint64_t addr;
 
-  if (irp->override >= 0)
+  if (i386_record_check_override (irp))
     {
       if (record_debug)
 	printf_unfiltered (_("Process record ignores the memory change "
@@ -4039,7 +4059,7 @@ reswitch:
       /* mov EAX */
     case 0xa2:
     case 0xa3:
-      if (ir.override >= 0)
+      if (i386_record_check_override (&ir))
         {
 	  if (record_debug)
 	    printf_unfiltered (_("Process record ignores the memory change "
@@ -4458,13 +4478,8 @@ reswitch:
                                       ir.regmap[X86_RECORD_REDI_REGNUM],
                                       &tmpulongest);
 
-          regcache_raw_read_unsigned (ir.regcache,
-                                      ir.regmap[X86_RECORD_ES_REGNUM],
-                                      &es);
-          regcache_raw_read_unsigned (ir.regcache,
-                                      ir.regmap[X86_RECORD_DS_REGNUM],
-                                      &ds);
-          if (ir.aflag && (es != ds))
+          ir.override = X86_RECORD_ES_REGNUM;
+          if (ir.aflag && i386_record_check_override (&ir))
             {
               /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
               if (record_debug)
@@ -5086,7 +5101,7 @@ reswitch:
 		opcode = opcode << 8 | ir.modrm;
 		goto no_support;
 	      }
-	    if (ir.override >= 0)
+	    if (i386_record_check_override (&ir))
 	      {
 		if (record_debug)
 		  printf_unfiltered (_("Process record ignores the memory "
@@ -5138,7 +5153,7 @@ reswitch:
 	  else
 	    {
 	      /* sidt */
-	      if (ir.override >= 0)
+	      if (i386_record_check_override (&ir))
 		{
 		  if (record_debug)
 		    printf_unfiltered (_("Process record ignores the memory "

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

end of thread, other threads:[~2009-09-07 11:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-29 16:12 [RFA/prec] Make i386 handle segment register better Hui Zhu
2009-08-29 21:34 ` Michael Snyder
2009-08-30  3:21   ` Hui Zhu
2009-09-05  2:42     ` Michael Snyder
2009-09-05  8:15       ` Mark Kettenis
2009-09-05 15:38         ` Hui Zhu
2009-09-06  6:52           ` Hui Zhu
2009-09-06 15:06             ` Hui Zhu
2009-09-07  0:07               ` Michael Snyder
2009-09-07 11:17                 ` Hui Zhu

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