From 4ffa4fc748a39a8ec5192c6247fc9f9b33217198 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 20 Jul 2012 11:22:32 +0000 Subject: 2012-07-20 Pedro Alves * 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/i386-tdep.c | 169 ++++++++++++-------------------------------------------- 1 file changed, 35 insertions(+), 134 deletions(-) (limited to 'gdb/i386-tdep.c') 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; -- cgit v1.1