gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / i386-tdep.c
index 836172b5cb06487c94655595bd2839a0c5224573..b354462cb92b547eaa277c48569942e67cf614a7 100644 (file)
@@ -2867,6 +2867,7 @@ struct i386_record_s
 {
   struct gdbarch *gdbarch;
   struct regcache *regcache;
+  CORE_ADDR orig_addr;
   CORE_ADDR addr;
   int aflag;
   int dflag;
@@ -3159,11 +3160,10 @@ i386_record_lea_modrm (struct i386_record_s *irp)
 
   if (irp->override >= 0)
     {
-      if (record_debug)
-       printf_unfiltered (_("Process record ignores the memory change "
-                            "of instruction at address %s because it "
-                            "can't get the value of the segment register.\n"),
-                          paddress (gdbarch, irp->addr));
+      warning (_("Process record ignores the memory change "
+                 "of instruction at address %s because it "
+                 "can't get the value of the segment register."),
+               paddress (gdbarch, irp->orig_addr));
       return 0;
     }
 
@@ -3221,6 +3221,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   memset (&ir, 0, sizeof (struct i386_record_s));
   ir.regcache = regcache;
   ir.addr = addr;
+  ir.orig_addr = addr;
   ir.aflag = 1;
   ir.dflag = 1;
   ir.override = -1;
@@ -3280,23 +3281,23 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
        case 0x67:
          prefixes |= PREFIX_ADDR;
          break;
-        case 0x40:
-        case 0x41:
-        case 0x42:
-        case 0x43:
-        case 0x44:
-        case 0x45:
-        case 0x46:
-        case 0x47:
-        case 0x48:
-        case 0x49:
-        case 0x4a:
-        case 0x4b:
-        case 0x4c:
-        case 0x4d:
-        case 0x4e:
-        case 0x4f:
-          if (ir.regmap[X86_RECORD_R8_REGNUM])
+        case 0x40:     /* i386 inc %eax */
+        case 0x41:     /* i386 inc %ecx */
+        case 0x42:     /* i386 inc %edx */
+        case 0x43:     /* i386 inc %ebx */
+        case 0x44:     /* i386 inc %esp */
+        case 0x45:     /* i386 inc %ebp */
+        case 0x46:     /* i386 inc %esi */
+        case 0x47:     /* i386 inc %edi */
+        case 0x48:     /* i386 dec %eax */
+        case 0x49:     /* i386 dec %ecx */
+        case 0x4a:     /* i386 dec %edx */
+        case 0x4b:     /* i386 dec %ebx */
+        case 0x4c:     /* i386 dec %esp */
+        case 0x4d:     /* i386 dec %ebp */
+        case 0x4e:     /* i386 dec %esi */
+        case 0x4f:     /* i386 dec %edi */
+          if (ir.regmap[X86_RECORD_R8_REGNUM]) /* 64 bit target */
             {
                /* REX */
                rex = 1;
@@ -3305,6 +3306,8 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
                ir.rex_x = (tmpu8 & 0x2) << 2;
                ir.rex_b = (tmpu8 & 0x1) << 3;
             }
+         else                                  /* 32 bit target */
+           goto out_prefixes;
           break;
        default:
          goto out_prefixes;
@@ -4039,12 +4042,11 @@ reswitch:
     case 0xa3:
       if (ir.override >= 0)
         {
-         if (record_debug)
-           printf_unfiltered (_("Process record ignores the memory change "
-                                "of instruction at address 0x%s because "
-                                "it can't get the value of the segment "
-                                "register.\n"),
-                              paddress (gdbarch, ir.addr));
+         warning (_("Process record ignores the memory change "
+                     "of instruction at address %s because "
+                     "it can't get the value of the segment "
+                     "register."),
+                   paddress (gdbarch, ir.orig_addr));
        }
       else
        {
@@ -4144,7 +4146,7 @@ reswitch:
        return -1;
       if (ir.mod == 3)
        {
-         ir.rm != ir.rex_b;
+         ir.rm |= ir.rex_b;
          if (ir.ot == OT_BYTE && !ir.regmap[X86_RECORD_R8_REGNUM])
            ir.rm &= 0x3;
          I386_RECORD_ARCH_LIST_ADD_REG (ir.rm);
@@ -4441,50 +4443,49 @@ reswitch:
       /* insS */
     case 0x6c:
     case 0x6d:
-      if ((opcode & 1) == 0)
-       ir.ot = OT_BYTE;
-      else
-       ir.ot = ir.dflag + OT_WORD;
       regcache_raw_read_unsigned (ir.regcache,
-                                  ir.regmap[X86_RECORD_REDI_REGNUM],
+                                  ir.regmap[X86_RECORD_RECX_REGNUM],
                                   &tmpulongest);
-      if (!ir.aflag)
-        {
-          tmpulongest &= 0xffff;
-          /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
-          if (record_debug)
-            printf_unfiltered (_("Process record ignores the memory change "
-                                 "of instruction at address 0x%s because "
-                                 "it can't get the value of the segment "
-                                 "register.\n"),
-                               paddress (gdbarch, ir.addr));
-        }
-      if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ))
+      if (tmpulongest)
         {
-          ULONGEST count, eflags;
+          ULONGEST es, ds;
+
+          if ((opcode & 1) == 0)
+           ir.ot = OT_BYTE;
+          else
+           ir.ot = ir.dflag + OT_WORD;
           regcache_raw_read_unsigned (ir.regcache,
                                       ir.regmap[X86_RECORD_REDI_REGNUM],
-                                      &count);
-          if (!ir.aflag)
-            count &= 0xffff;
+                                      &tmpulongest);
+
           regcache_raw_read_unsigned (ir.regcache,
-                                      ir.regmap[X86_RECORD_EFLAGS_REGNUM],
-                                      &eflags);
-          if ((eflags >> 10) & 0x1)
-            tmpulongest -= (count - 1) * (1 << ir.ot);
-          if (record_arch_list_add_mem (tmpulongest, count * (1 << ir.ot)))
-            return -1;
-          I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM);
-        }
-      else
-        {
-          if (record_arch_list_add_mem (tmpulongest, 1 << ir.ot))
-            return -1;
-        }
-      if (opcode == 0xa4 || opcode == 0xa5)
-        I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RESI_REGNUM);
-      I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDI_REGNUM);
-      I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_EFLAGS_REGNUM);
+                                      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))
+            {
+              /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
+              warning (_("Process record ignores the memory "
+                         "change of instruction at address %s "
+                         "because it can't get the value of the "
+                         "ES segment register."),
+                       paddress (gdbarch, ir.orig_addr));
+            }
+          else
+            {
+              if (record_arch_list_add_mem (tmpulongest, 1 << ir.ot))
+                return -1;
+            }
+
+          if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ))
+            I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM);
+          if (opcode == 0xa4 || opcode == 0xa5)
+            I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RESI_REGNUM);
+          I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDI_REGNUM);
+          I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_EFLAGS_REGNUM);
+       }
       break;
 
       /* cmpsS */
@@ -5089,13 +5090,12 @@ reswitch:
              }
            if (ir.override >= 0)
              {
-               if (record_debug)
-                 printf_unfiltered (_("Process record ignores the memory "
-                                      "change of instruction at "
-                                      "address %s because it can't get "
-                                      "the value of the segment "
-                                      "register.\n"),
-                                    paddress (gdbarch, ir.addr));
+               warning (_("Process record ignores the memory "
+                           "change of instruction at "
+                           "address %s because it can't get "
+                           "the value of the segment "
+                           "register."),
+                         paddress (gdbarch, ir.orig_addr));
              }
            else
              {
@@ -5141,13 +5141,12 @@ reswitch:
              /* sidt */
              if (ir.override >= 0)
                {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record ignores the memory "
-                                        "change of instruction at "
-                                        "address %s because it can't get "
-                                        "the value of the segment "
-                                        "register.\n"),
-                                      paddress (gdbarch, ir.addr));
+                 warning (_("Process record ignores the memory "
+                             "change of instruction at "
+                             "address %s because it can't get "
+                             "the value of the segment "
+                             "register."),
+                           paddress (gdbarch, ir.orig_addr));
                }
              else
                {
@@ -5173,6 +5172,19 @@ reswitch:
          break;
          /* lgdt */
        case 2:
+         if (ir.mod == 3)
+           {
+             /* xgetbv */
+             if (ir.rm == 0)
+               {
+                 I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REAX_REGNUM);
+                 I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDX_REGNUM);
+                 break;
+               }
+             /* xsetbv */
+             else if (ir.rm == 1)
+               break;
+           }
          /* lidt */
        case 3:
          if (ir.mod == 3)
This page took 0.064808 seconds and 4 git commands to generate.