i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
{
struct gdbarch *gdbarch = irp->gdbarch;
- int8_t addr8;
- int16_t addr16;
- int32_t addr32;
- ULONGEST addr64;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte buf[4];
+ ULONGEST offset64;
*addr = 0;
if (irp->aflag)
if ((base & 7) == 5)
{
base = 0xff;
- if (target_read_memory (irp->addr, (gdb_byte *) &addr32, 4))
+ if (target_read_memory (irp->addr, buf, 4))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading "
return -1;
}
irp->addr += 4;
- *addr = addr32;
+ *addr = extract_signed_integer (buf, 4, byte_order);
if (irp->regmap[X86_RECORD_R8_REGNUM] && !havesib)
*addr += irp->addr + irp->rip_offset;
}
}
break;
case 1:
- if (target_read_memory (irp->addr, &addr8, 1))
+ if (target_read_memory (irp->addr, buf, 1))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading memory "
return -1;
}
irp->addr++;
- *addr = addr8;
+ *addr = (int8_t) buf[0];
break;
case 2:
- if (target_read_memory (irp->addr, (gdb_byte *) &addr32, 4))
+ if (target_read_memory (irp->addr, buf, 4))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading memory "
paddress (gdbarch, irp->addr));
return -1;
}
- *addr = addr32;
+ *addr = extract_signed_integer (buf, 4, byte_order);
irp->addr += 4;
break;
}
- addr64 = 0;
+ offset64 = 0;
if (base != 0xff)
{
if (base == 4 && irp->popl_esp_hack)
*addr += irp->popl_esp_hack;
regcache_raw_read_unsigned (irp->regcache, irp->regmap[base],
- &addr64);
+ &offset64);
}
if (irp->aflag == 2)
{
- *addr += addr64;
+ *addr += offset64;
}
else
- *addr = (uint32_t) (addr64 + *addr);
+ *addr = (uint32_t) (offset64 + *addr);
if (havesib && (index != 4 || scale != 0))
{
regcache_raw_read_unsigned (irp->regcache, irp->regmap[index],
- &addr64);
+ &offset64);
if (irp->aflag == 2)
- *addr += addr64 << scale;
+ *addr += offset64 << scale;
else
- *addr = (uint32_t) (*addr + (addr64 << scale));
+ *addr = (uint32_t) (*addr + (offset64 << scale));
}
}
else
case 0:
if (irp->rm == 6)
{
- if (target_read_memory (irp->addr, (gdb_byte *) &addr16, 2))
+ if (target_read_memory (irp->addr, buf, 2))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading "
return -1;
}
irp->addr += 2;
- *addr = addr16;
+ *addr = extract_signed_integer (buf, 2, byte_order);
irp->rm = 0;
goto no_rm;
}
}
break;
case 1:
- if (target_read_memory (irp->addr, &addr8, 1))
+ if (target_read_memory (irp->addr, buf, 1))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading memory "
return -1;
}
irp->addr++;
- *addr = addr8;
+ *addr = (int8_t) buf[0];
break;
case 2:
- if (target_read_memory (irp->addr, (gdb_byte *) &addr16, 2))
+ if (target_read_memory (irp->addr, buf, 2))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading memory "
return -1;
}
irp->addr += 2;
- *addr = addr16;
+ *addr = extract_signed_integer (buf, 2, byte_order);
break;
}
case 0:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBX_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_RESI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 1:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBX_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REDI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 2:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBP_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_RESI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 3:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBP_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REDI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 4:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_RESI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 5:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REDI_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 6:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBP_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
case 7:
regcache_raw_read_unsigned (irp->regcache,
irp->regmap[X86_RECORD_REBX_REGNUM],
- &addr64);
- *addr = (uint32_t) (*addr + addr64);
+ &offset64);
+ *addr = (uint32_t) (*addr + offset64);
break;
}
*addr &= 0xffff;
i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
CORE_ADDR input_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int prefixes = 0;
int regnum = 0;
uint32_t opcode;
uint8_t opcode8;
ULONGEST addr;
+ gdb_byte buf[MAX_REGISTER_SIZE];
struct i386_record_s ir;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
int rex = 0;
ir.ot = ir.dflag + OT_WORD;
if (ir.aflag == 2)
{
- uint64_t addr64;
-
- if (target_read_memory (ir.addr, (gdb_byte *) &addr64, 8))
+ if (target_read_memory (ir.addr, buf, 8))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading "
return -1;
}
ir.addr += 8;
- addr = addr64;
+ addr = extract_unsigned_integer (buf, 8, byte_order);
}
else if (ir.aflag)
{
- uint32_t addr32;
-
- if (target_read_memory (ir.addr, (gdb_byte *) &addr32, 4))
+ if (target_read_memory (ir.addr, buf, 4))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading "
return -1;
}
ir.addr += 4;
- addr = addr32;
+ addr = extract_unsigned_integer (buf, 4, byte_order);
}
else
{
- uint16_t addr16;
-
- if (target_read_memory (ir.addr, (gdb_byte *) &addr16, 2))
+ if (target_read_memory (ir.addr, buf, 2))
{
if (record_debug)
printf_unfiltered (_("Process record: error reading "
return -1;
}
ir.addr += 2;
- addr = addr16;
+ addr = extract_unsigned_integer (buf, 2, byte_order);
}
if (record_arch_list_add_mem (addr, 1 << ir.ot))
return -1;