2012-07-20 Pedro Alves <palves@redhat.com>
authorPedro Alves <palves@redhat.com>
Fri, 20 Jul 2012 11:22:32 +0000 (11:22 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 20 Jul 2012 11:22:32 +0000 (11:22 +0000)
* i386-tdep.c (i386_record_modrm, i386_record_lea_modrm_addr)
(i386_process_record): Use record_read_memory.
* record.c (record_read_memory): New function.
(record_arch_list_add_mem, record_exec_insn): Use
record_read_memory.
* record.h (record_read_memory): Declare.

gdb/ChangeLog
gdb/i386-tdep.c
gdb/record.c
gdb/record.h

index f88fbeb98a269470883ff96941eb16546620971b..15960ff499e2433da898e0a88a98549ce295e986 100644 (file)
@@ -1,3 +1,12 @@
+2012-07-20  Pedro Alves  <palves@redhat.com>
+
+       * i386-tdep.c (i386_record_modrm, i386_record_lea_modrm_addr)
+       (i386_process_record): Use record_read_memory.
+       * record.c (record_read_memory): New function.
+       (record_arch_list_add_mem, record_exec_insn): Use
+       record_read_memory.
+       * record.h (record_read_memory): Declare.
+
 2012-07-20  Yao Qi  <yao@codesourcery.com>
 
        * cli/cli-setshow.c (do_setshow_command): Don't check pointer is
index 6a029069657c9b301a081f17e79dcdba71113ae1..9227245034e41ffcfb61c8c940d6196573a488b8 100644 (file)
@@ -3941,14 +3941,9 @@ i386_record_modrm (struct i386_record_s *irp)
 {
   struct gdbarch *gdbarch = irp->gdbarch;
 
-  if (target_read_memory (irp->addr, &irp->modrm, 1))
-    {
-      if (record_debug)
-       printf_unfiltered (_("Process record: error reading memory at "
-                            "addr %s len = 1.\n"),
-                          paddress (gdbarch, irp->addr));
-      return -1;
-    }
+  if (record_read_memory (gdbarch, irp->addr, &irp->modrm, 1))
+    return -1;
+
   irp->addr++;
   irp->mod = (irp->modrm >> 6) & 3;
   irp->reg = (irp->modrm >> 3) & 7;
@@ -3982,14 +3977,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
       if (base == 4)
        {
          havesib = 1;
-         if (target_read_memory (irp->addr, &byte, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, &byte, 1))
+           return -1;
          irp->addr++;
          scale = (byte >> 6) & 3;
          index = ((byte >> 3) & 7) | irp->rex_x;
@@ -4003,14 +3992,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
          if ((base & 7) == 5)
            {
              base = 0xff;
-             if (target_read_memory (irp->addr, buf, 4))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr %s len = 4.\n"),
-                                      paddress (gdbarch, irp->addr));
-                 return -1;
-               }
+             if (record_read_memory (gdbarch, irp->addr, buf, 4))
+               return -1;
              irp->addr += 4;
              *addr = extract_signed_integer (buf, 4, byte_order);
              if (irp->regmap[X86_RECORD_R8_REGNUM] && !havesib)
@@ -4018,26 +4001,14 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
            }
          break;
        case 1:
-         if (target_read_memory (irp->addr, buf, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 1))
+           return -1;
          irp->addr++;
          *addr = (int8_t) buf[0];
          break;
        case 2:
-         if (target_read_memory (irp->addr, buf, 4))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 4.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 4))
+           return -1;
          *addr = extract_signed_integer (buf, 4, byte_order);
          irp->addr += 4;
          break;
@@ -4076,14 +4047,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
        case 0:
          if (irp->rm == 6)
            {
-             if (target_read_memory (irp->addr, buf, 2))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr %s len = 2.\n"),
-                                      paddress (gdbarch, irp->addr));
-                 return -1;
-               }
+             if (record_read_memory (gdbarch, irp->addr, buf, 2))
+               return -1;
              irp->addr += 2;
              *addr = extract_signed_integer (buf, 2, byte_order);
              irp->rm = 0;
@@ -4091,26 +4056,14 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
            }
          break;
        case 1:
-         if (target_read_memory (irp->addr, buf, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 1))
+           return -1;
          irp->addr++;
          *addr = (int8_t) buf[0];
          break;
        case 2:
-         if (target_read_memory (irp->addr, buf, 2))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 2.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 2))
+           return -1;
          irp->addr += 2;
          *addr = extract_signed_integer (buf, 2, byte_order);
          break;
@@ -4360,14 +4313,8 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   /* prefixes */
   while (1)
     {
-      if (target_read_memory (ir.addr, &opcode8, 1))
-       {
-         if (record_debug)
-           printf_unfiltered (_("Process record: error reading memory at "
-                                "addr %s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-         return -1;
-       }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       switch (opcode8) /* Instruction prefixes */
        {
@@ -4458,14 +4405,8 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   switch (opcode)
     {
     case 0x0f:
-      if (target_read_memory (ir.addr, &opcode8, 1))
-       {
-         if (record_debug)
-           printf_unfiltered (_("Process record: error reading memory at "
-                                "addr %s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-         return -1;
-       }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       opcode = (uint32_t) opcode8 | 0x0f00;
       goto reswitch;
@@ -5130,40 +5071,22 @@ Do you want to stop the program?"),
            ir.ot = ir.dflag + OT_WORD;
          if (ir.aflag == 2)
            {
-              if (target_read_memory (ir.addr, buf, 8))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 8.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 8))
+               return -1;
              ir.addr += 8;
              addr = extract_unsigned_integer (buf, 8, byte_order);
            }
           else if (ir.aflag)
            {
-              if (target_read_memory (ir.addr, buf, 4))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 4.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 4))
+               return -1;
              ir.addr += 4;
               addr = extract_unsigned_integer (buf, 4, byte_order);
            }
           else
            {
-              if (target_read_memory (ir.addr, buf, 2))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 2.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 2))
+               return -1;
              ir.addr += 2;
               addr = extract_unsigned_integer (buf, 2, byte_order);
            }
@@ -6135,14 +6058,8 @@ Do you want to stop the program?"),
       break;
 
     case 0x9b:    /* fwait */
-      if (target_read_memory (ir.addr, &opcode8, 1))
-        {
-          if (record_debug)
-            printf_unfiltered (_("Process record: error reading memory at "
-                                "addr 0x%s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-          return -1;
-        }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       opcode = (uint32_t) opcode8;
       ir.addr++;
       goto reswitch;
@@ -6161,14 +6078,8 @@ Do you want to stop the program?"),
       {
        int ret;
        uint8_t interrupt;
-       if (target_read_memory (ir.addr, &interrupt, 1))
-         {
-           if (record_debug)
-             printf_unfiltered (_("Process record: error reading memory "
-                                  "at addr %s len = 1.\n"),
-                                paddress (gdbarch, ir.addr));
-           return -1;
-         }
+       if (record_read_memory (gdbarch, ir.addr, &interrupt, 1))
+         return -1;
        ir.addr++;
        if (interrupt != 0x80
            || tdep->i386_intx80_record == NULL)
@@ -6638,13 +6549,8 @@ Do you want to stop the program?"),
     case 0x0f0f:    /* 3DNow! data */
       if (i386_record_modrm (&ir))
        return -1;
-      if (target_read_memory (ir.addr, &opcode8, 1))
-        {
-         printf_unfiltered (_("Process record: error reading memory at "
-                              "addr %s len = 1.\n"),
-                            paddress (gdbarch, ir.addr));
-          return -1;
-        }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       switch (opcode8)
         {
@@ -6911,13 +6817,8 @@ reswitch_prefix_add:
         case 0xf20f38:
         case 0x0f3a:
         case 0x660f3a:
-          if (target_read_memory (ir.addr, &opcode8, 1))
-            {
-             printf_unfiltered (_("Process record: error reading memory at "
-                                  "addr %s len = 1.\n"),
-                                paddress (gdbarch, ir.addr));
-              return -1;
-            }
+          if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+           return -1;
           ir.addr++;
           opcode = (uint32_t) opcode8 | opcode << 8;
           goto reswitch_prefix_add;
index e1a612102aafceea20b3fc3e91017338fbec3179..ac55cdf8a0d210b3455c95fe54e5e1c3bc7fa330 100644 (file)
@@ -485,6 +485,20 @@ record_arch_list_add_reg (struct regcache *regcache, int regnum)
   return 0;
 }
 
+int
+record_read_memory (struct gdbarch *gdbarch,
+                   CORE_ADDR memaddr, gdb_byte *myaddr,
+                   ssize_t len)
+{
+  int ret = target_read_memory (memaddr, myaddr, len);
+
+  if (ret && record_debug)
+    printf_unfiltered (_("Process record: error reading memory "
+                        "at addr %s len = %ld.\n"),
+                      paddress (gdbarch, memaddr), (long) len);
+  return ret;
+}
+
 /* Record the value of a region of memory whose address is ADDR and
    length is LEN to record_arch_list.  */
 
@@ -504,13 +518,8 @@ record_arch_list_add_mem (CORE_ADDR addr, int len)
 
   rec = record_mem_alloc (addr, len);
 
-  if (target_read_memory (addr, record_get_loc (rec), len))
+  if (record_read_memory (target_gdbarch, addr, record_get_loc (rec), len))
     {
-      if (record_debug)
-       fprintf_unfiltered (gdb_stdlog,
-                           "Process record: error reading memory at "
-                           "addr = %s len = %d.\n",
-                           paddress (target_gdbarch, addr), len);
       record_mem_release (rec);
       return -1;
     }
@@ -739,15 +748,9 @@ record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch,
                                   paddress (gdbarch, entry->u.mem.addr),
                                   entry->u.mem.len);
 
-            if (target_read_memory (entry->u.mem.addr, mem, entry->u.mem.len))
-              {
-                entry->u.mem.mem_entry_not_accessible = 1;
-                if (record_debug)
-                  warning (_("Process record: error reading memory at "
-                            "addr = %s len = %d."),
-                           paddress (gdbarch, entry->u.mem.addr),
-                           entry->u.mem.len);
-              }
+            if (record_read_memory (gdbarch,
+                                   entry->u.mem.addr, mem, entry->u.mem.len))
+             entry->u.mem.mem_entry_not_accessible = 1;
             else
               {
                 if (target_write_memory (entry->u.mem.addr, 
index 84396e66cbecf7d1210a7752c8d23bb1eab52bc9..ee591eafe67838b9c8b1f21cfed62505e1408453 100644 (file)
@@ -30,4 +30,10 @@ extern int record_arch_list_add_mem (CORE_ADDR addr, int len);
 extern int record_arch_list_add_end (void);
 extern struct cleanup *record_gdb_operation_disable_set (void);
 
+/* Wrapper for target_read_memory that prints a debug message if
+   reading memory fails.  */
+extern int record_read_memory (struct gdbarch *gdbarch,
+                              CORE_ADDR memaddr, gdb_byte *myaddr,
+                              ssize_t len);
+
 #endif /* _RECORD_H_ */
This page took 0.0347499999999999 seconds and 4 git commands to generate.