diff options
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/i386-tdep.c | 169 | ||||
-rw-r--r-- | gdb/record.c | 33 | ||||
-rw-r--r-- | gdb/record.h | 6 |
4 files changed, 68 insertions, 149 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f88fbeb..15960ff 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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 diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 6a02906..9227245 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -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; diff --git a/gdb/record.c b/gdb/record.c index e1a6121..ac55cdf 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -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, diff --git a/gdb/record.h b/gdb/record.h index 84396e6..ee591ea 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -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_ */ |