{
CORE_ADDR current_pc;
int ix, i;
- gdb_byte op;
struct i386_insn *insn;
insn = i386_match_insn (pc, insn_patterns);
return 0;
}
+/* Implementation for set_gdbarch_push_dummy_code. */
+
+static CORE_ADDR
+i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
+ struct value **args, int nargs, struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+ struct regcache *regcache)
+{
+ /* Use 0xcc breakpoint - 1 byte. */
+ *bp_addr = sp - 1;
+ *real_pc = funaddr;
+
+ /* Keep the stack aligned. */
+ return sp - 16;
+}
+
static CORE_ADDR
i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
for (write_pass = 0; write_pass < 2; write_pass++)
{
int args_space_used = 0;
- int have_16_byte_aligned_arg = 0;
if (struct_return)
{
else
{
if (i386_16_byte_align_p (value_enclosing_type (args[i])))
- {
- args_space = align_up (args_space, 16);
- have_16_byte_aligned_arg = 1;
- }
+ args_space = align_up (args_space, 16);
args_space += align_up (len, 4);
}
}
if (!write_pass)
{
- if (have_16_byte_aligned_arg)
- args_space = align_up (args_space, 16);
sp -= args_space;
+
+ /* The original System V ABI only requires word alignment,
+ but modern incarnations need 16-byte alignment in order
+ to support SSE. Since wasting a few bytes here isn't
+ harmful we unconditionally enforce 16-byte alignment. */
+ sp &= ~0xf;
}
}
from WRITEBUF into REGCACHE. */
static enum return_value_convention
-i386_return_value (struct gdbarch *gdbarch, struct type *func_type,
+i386_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
{
type = check_typedef (TYPE_FIELD_TYPE (type, 0));
- return i386_return_value (gdbarch, func_type, type, regcache,
+ return i386_return_value (gdbarch, function, type, regcache,
readbuf, writebuf);
}
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. */
-static struct type *
+struct type *
i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
{
if (i386_mmx_regnum_p (gdbarch, regnum))
i386_stap_parse_special_token (struct gdbarch *gdbarch,
struct stap_parse_info *p)
{
- const char *s = p->arg;
-
/* In order to parse special tokens, we use a state-machine that go
through every known token and try to get a match. */
enum
{
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- CORE_ADDR sp = get_frame_register_unsigned (frame, I386_ESP_REGNUM);
+ CORE_ADDR sp = get_frame_register_unsigned (frame, I386_ESP_REGNUM);
return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4, byte_order);
}
const int *regmap;
};
-/* Parse "modrm" part in current memory address that irp->addr point to
- Return -1 if something wrong. */
+/* Parse the "modrm" part of the memory address irp->addr points at.
+ Returns -1 if something goes wrong, 0 otherwise. */
static int
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;
return 0;
}
-/* Get the memory address that current instruction write to and set it to
- the argument "addr".
- Return -1 if something wrong. */
+/* Extract the memory address that the current instruction writes to,
+ and return it in *ADDR. Return -1 if something goes wrong. */
static int
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;
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)
}
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;
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;
}
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;
return 0;
}
-/* Record the value of the memory that willbe changed in current instruction
- to "record_arch_list".
- Return -1 if something wrong. */
+/* Record the address and contents of the memory that will be changed
+ by the current instruction. Return -1 if something goes wrong, 0
+ otherwise. */
static int
i386_record_lea_modrm (struct i386_record_s *irp)
return 0;
}
-/* Record the push operation to "record_arch_list".
- Return -1 if something wrong. */
+/* Record the effects of a push operation. Return -1 if something
+ goes wrong, 0 otherwise. */
static int
i386_record_push (struct i386_record_s *irp, int size)
#define I386_SAVE_FPU_ENV 0xfffe
#define I386_SAVE_FPU_ENV_REG_STACK 0xffff
-/* Record the value of floating point registers which will be changed
- by the current instruction to "record_arch_list". Return -1 if
- something is wrong. */
+/* Record the values of the floating point registers which will be
+ changed by the current instruction. Returns -1 if something is
+ wrong, 0 otherwise. */
static int i386_record_floats (struct gdbarch *gdbarch,
struct i386_record_s *ir,
return 0;
}
-/* Parse the current instruction and record the values of the registers and
- memory that will be changed in current instruction to "record_arch_list".
- Return -1 if something wrong. */
+/* Parse the current instruction, and record the values of the
+ registers and memory that will be changed by the current
+ instruction. Returns -1 if something goes wrong, 0 otherwise. */
#define I386_RECORD_ARCH_LIST_ADD_REG(regnum) \
record_arch_list_add_reg (ir.regcache, ir.regmap[(regnum)])
int prefixes = 0;
int regnum = 0;
uint32_t opcode;
- uint8_t opcode8;
+ uint8_t opcode8;
ULONGEST addr;
gdb_byte buf[MAX_REGISTER_SIZE];
struct i386_record_s ir;
/* 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 */
{
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;
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);
}
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;
{
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)
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)
{
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;
set_gdbarch_get_longjmp_target (gdbarch, i386_get_longjmp_target);
/* Call dummy code. */
+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+ set_gdbarch_push_dummy_code (gdbarch, i386_push_dummy_code);
set_gdbarch_push_dummy_call (gdbarch, i386_push_dummy_call);
set_gdbarch_frame_align (gdbarch, i386_frame_align);
tdep->num_mmx_regs = 8;
tdep->num_ymm_regs = 0;
+ tdep->sp_regnum_from_eax = -1;
+ tdep->pc_regnum_from_eax = -1;
+
tdesc_data = tdesc_data_alloc ();
set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction);
/* Support dword pseudo-register if it hasn't been disabled. */
tdep->eax_regnum = ymm0_regnum;
ymm0_regnum += tdep->num_dword_regs;
+ if (tdep->sp_regnum_from_eax != -1)
+ set_gdbarch_sp_regnum (gdbarch,
+ (tdep->eax_regnum
+ + tdep->sp_regnum_from_eax));
+ if (tdep->pc_regnum_from_eax != -1)
+ set_gdbarch_pc_regnum (gdbarch,
+ (tdep->eax_regnum
+ + tdep->pc_regnum_from_eax));
}
else
tdep->eax_regnum = -1;