Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
- 2010 Free Software Foundation, Inc.
+ 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
static int
i386_absolute_jmp_p (const gdb_byte *insn)
{
- /* jmp far (absolute address in operand) */
+ /* jmp far (absolute address in operand). */
if (insn[0] == 0xea)
return 1;
if (insn[0] == 0xff)
{
- /* jump near, absolute indirect (/4) */
+ /* jump near, absolute indirect (/4). */
if ((insn[1] & 0x38) == 0x20)
return 1;
- /* jump far, absolute indirect (/5) */
+ /* jump far, absolute indirect (/5). */
if ((insn[1] & 0x38) == 0x28)
return 1;
}
static int
i386_absolute_call_p (const gdb_byte *insn)
{
- /* call far, absolute */
+ /* call far, absolute. */
if (insn[0] == 0x9a)
return 1;
if (insn[0] == 0xff)
{
- /* Call near, absolute indirect (/2) */
+ /* Call near, absolute indirect (/2). */
if ((insn[1] & 0x38) == 0x10)
return 1;
- /* Call far, absolute indirect (/3) */
+ /* Call far, absolute indirect (/3). */
if ((insn[1] & 0x38) == 0x18)
return 1;
}
{
switch (insn[0])
{
- case 0xc2: /* ret near, pop N bytes */
+ case 0xc2: /* ret near, pop N bytes. */
case 0xc3: /* ret near */
- case 0xca: /* ret far, pop N bytes */
+ case 0xca: /* ret far, pop N bytes. */
case 0xcb: /* ret far */
case 0xcf: /* iret */
return 1;
if (i386_absolute_call_p (insn))
return 1;
- /* call near, relative */
+ /* call near, relative. */
if (insn[0] == 0xe8)
return 1;
/* Where "ret" in the original code will return to. */
ret_addr = oldloc + insn_length;
- push_buf[0] = 0x68; /* pushq $... */
+ push_buf[0] = 0x68; /* pushq $... */
memcpy (&push_buf[1], &ret_addr, 4);
/* Push the push. */
append_insns (to, 5, push_buf);
long delta = 0;
int data16 = 0;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
+
if (op == 0x66)
{
data16 = 1;
if (current_pc <= pc)
return pc;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op != 0x58) /* popl %eax */
return pc;
- target_read_memory (pc + 1, buf, 4);
+ if (target_read_memory (pc + 1, buf, 4))
+ return pc;
+
if (memcmp (buf, proto1, 3) != 0 && memcmp (buf, proto2, 4) != 0)
return pc;
gdb_byte buf[8];
gdb_byte op;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op == 0x68 || op == 0x6a)
{
struct i386_insn *insn;
gdb_byte op;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return NULL;
for (insn = skip_insns; insn->len > 0; insn++)
{
gdb_assert (insn->len > 1);
gdb_assert (insn->len <= I386_MAX_MATCHED_INSN_LEN);
- target_read_memory (pc + 1, buf, insn->len - 1);
+ if (target_read_memory (pc + 1, buf, insn->len - 1))
+ return NULL;
+
for (i = 1; i < insn->len; i++)
{
if ((buf[i - 1] & insn->mask[i]) != insn->insn[i])
struct i386_insn i386_frame_setup_skip_insns[] =
{
- /* Check for `movb imm8, r' and `movl imm32, r'.
+ /* Check for `movb imm8, r' and `movl imm32, r'.
??? Should we handle 16-bit operand-sizes here? */
gdb_byte op;
int check = 1;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
while (check)
{
if (op == 0x90)
{
pc += 1;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
check = 1;
}
/* Ignore no-op instruction `mov %edi, %edi'.
else if (op == 0x8b)
{
- target_read_memory (pc + 1, &op, 1);
+ if (target_read_memory (pc + 1, &op, 1))
+ return pc;
+
if (op == 0xff)
{
pc += 2;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
+
check = 1;
}
}
if (limit <= pc)
return limit;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op == 0x55) /* pushl %ebp */
{
if (limit <= pc + skip)
return limit;
- target_read_memory (pc + skip, &op, 1);
+ if (target_read_memory (pc + skip, &op, 1))
+ return pc + skip;
/* Check for `movl %esp, %ebp' -- can be written in two ways. */
switch (op)
NOTE: You can't subtract a 16-bit immediate from a 32-bit
reg, so we don't have to worry about a data16 prefix. */
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op == 0x83)
{
/* `subl' with 8-bit immediate. */
offset -= cache->locals;
for (i = 0; i < 8 && pc < current_pc; i++)
{
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op < 0x50 || op > 0x57)
break;
for (i = 0; i < 6; i++)
{
- target_read_memory (pc + i, &op, 1);
+ if (target_read_memory (pc + i, &op, 1))
+ return pc;
+
if (pic_pat[i] != op)
break;
}
{
int delta = 6;
- target_read_memory (pc + delta, &op, 1);
+ if (target_read_memory (pc + delta, &op, 1))
+ return pc;
if (op == 0x89) /* movl %ebx, x(%ebp) */
{
else /* Unexpected instruction. */
delta = 0;
- target_read_memory (pc + delta, &op, 1);
+ if (target_read_memory (pc + delta, &op, 1))
+ return pc;
}
/* addl y,%ebx */
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte op;
- target_read_memory (pc, &op, 1);
+ if (target_read_memory (pc, &op, 1))
+ return pc;
if (op == 0xe8)
{
gdb_byte buf[4];
}
else
internal_error (__FILE__, __LINE__,
- _("Cannot extract return value of %d bytes long."), len);
+ _("Cannot extract return value of %d bytes long."),
+ len);
}
}
init_vector_type (bt->builtin_int128, 2));
TYPE_VECTOR (t) = 1;
- TYPE_NAME (t) = "builtin_type_vec128i";
+ TYPE_NAME (t) = "builtin_type_vec256i";
tdep->i386_ymm_type = t;
}
}
/* Return the GDB type object for the "standard" data type of data in
- register REGNUM. */
+ register REGNUM. */
static struct type *
i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
{
regnum -= tdep->ymm0_regnum;
- /* Extract (always little endian). Read lower 128bits. */
+ /* Extract (always little endian). Read lower 128bits. */
regcache_raw_read (regcache,
I387_XMM0_REGNUM (tdep) + regnum,
raw_buf);
needs any special handling. */
static int
-i386_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type)
+i386_convert_register_p (struct gdbarch *gdbarch,
+ int regnum, struct type *type)
{
int len = TYPE_LENGTH (type);
};
/* Parse "modrm" part in current memory address that irp->addr point to
- Return -1 if something wrong. */
+ Return -1 if something wrong. */
static int
i386_record_modrm (struct i386_record_s *irp)
/* Get the memory address that current instruction write to and set it to
the argument "addr".
- Return -1 if something wrong. */
+ Return -1 if something wrong. */
static int
i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
/* Record the value of the memory that willbe changed in current instruction
to "record_arch_list".
- Return -1 if something wrong. */
+ Return -1 if something wrong. */
static int
i386_record_lea_modrm (struct i386_record_s *irp)
}
/* Record the push operation to "record_arch_list".
- Return -1 if something wrong. */
+ Return -1 if something wrong. */
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 value of floating point registers which will be changed
+ by the current instruction to "record_arch_list". Return -1 if
+ something is wrong. */
static int i386_record_floats (struct gdbarch *gdbarch,
struct i386_record_s *ir,
/* 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. */
+ Return -1 if something wrong. */
#define I386_RECORD_ARCH_LIST_ADD_REG(regnum) \
record_arch_list_add_reg (ir.regcache, ir.regmap[(regnum)])
else if (ir.regmap[X86_RECORD_R8_REGNUM])
ir.aflag = 2;
- /* now check op code */
+ /* Now check op code. */
opcode = (uint32_t) opcode8;
reswitch:
switch (opcode)
ir.addr -= 1;
goto no_support;
}
+ /* FALLTHROUGH */
case 0x0fb2: /* lss Gv */
case 0x0fb4: /* lfs Gv */
case 0x0fb5: /* lgs Gv */
ir.reg |= ((opcode & 7) << 3);
if (ir.mod != 3)
{
- /* Memory. */
+ /* Memory. */
uint64_t addr64;
if (i386_record_lea_modrm_addr (&ir, &addr64))
ir.addr -= 1;
goto no_support;
}
+ /* FALLTHROUGH */
case 0xf5: /* cmc */
case 0xf8: /* clc */
case 0xf9: /* stc */
case 0x660f3804: /* pmaddubsw */
case 0x660f3805: /* phsubw */
case 0x660f3806: /* phsubd */
- case 0x660f3807: /* phaddsw */
+ case 0x660f3807: /* phsubsw */
case 0x660f3808: /* psignb */
case 0x660f3809: /* psignw */
case 0x660f380a: /* psignd */
case 0x660f63: /* packsswb */
case 0x660f64: /* pcmpgtb */
case 0x660f65: /* pcmpgtw */
- case 0x660f66: /* pcmpgtl */
+ case 0x660f66: /* pcmpgtd */
case 0x660f67: /* packuswb */
case 0x660f68: /* punpckhbw */
case 0x660f69: /* punpckhwd */
case 0xf30f70: /* pshufhw */
case 0x660f74: /* pcmpeqb */
case 0x660f75: /* pcmpeqw */
- case 0x660f76: /* pcmpeql */
+ case 0x660f76: /* pcmpeqd */
case 0x660f7c: /* haddpd */
case 0xf20f7c: /* haddps */
case 0x660f7d: /* hsubpd */
case 0x660fed: /* paddsw */
case 0x660fee: /* pmaxsw */
case 0x660fef: /* pxor */
- case 0x660ff0: /* lddqu */
+ case 0xf20ff0: /* lddqu */
case 0x660ff1: /* psllw */
case 0x660ff2: /* pslld */
case 0x660ff3: /* psllq */
case 0x660ff6: /* psadbw */
case 0x660ff8: /* psubb */
case 0x660ff9: /* psubw */
- case 0x660ffa: /* psubl */
+ case 0x660ffa: /* psubd */
case 0x660ffb: /* psubq */
case 0x660ffc: /* paddb */
case 0x660ffd: /* paddw */
- case 0x660ffe: /* paddl */
+ case 0x660ffe: /* paddd */
if (i386_record_modrm (&ir))
return -1;
ir.reg |= rex_r;
|| opcode == 0x0f17 || opcode == 0x660f17)
goto no_support;
ir.rm |= ir.rex_b;
- if (!i386_xmm_regnum_p (gdbarch, I387_XMM0_REGNUM (tdep) + ir.rm))
+ if (!i386_xmm_regnum_p (gdbarch,
+ I387_XMM0_REGNUM (tdep) + ir.rm))
goto no_support;
record_arch_list_add_reg (ir.regcache,
I387_XMM0_REGNUM (tdep) + ir.rm);
case 0x0f3804: /* pmaddubsw */
case 0x0f3805: /* phsubw */
case 0x0f3806: /* phsubd */
- case 0x0f3807: /* phaddsw */
+ case 0x0f3807: /* phsubsw */
case 0x0f3808: /* psignb */
case 0x0f3809: /* psignw */
case 0x0f380a: /* psignd */
case 0x0f63: /* packsswb */
case 0x0f64: /* pcmpgtb */
case 0x0f65: /* pcmpgtw */
- case 0x0f66: /* pcmpgtl */
+ case 0x0f66: /* pcmpgtd */
case 0x0f67: /* packuswb */
case 0x0f68: /* punpckhbw */
case 0x0f69: /* punpckhwd */
case 0x0f70: /* pshufw */
case 0x0f74: /* pcmpeqb */
case 0x0f75: /* pcmpeqw */
- case 0x0f76: /* pcmpeql */
+ case 0x0f76: /* pcmpeqd */
case 0x0fc4: /* pinsrw */
case 0x0fd1: /* psrlw */
case 0x0fd2: /* psrld */
case 0x0ff6: /* psadbw */
case 0x0ff8: /* psubb */
case 0x0ff9: /* psubw */
- case 0x0ffa: /* psubl */
+ case 0x0ffa: /* psubd */
case 0x0ffb: /* psubq */
case 0x0ffc: /* paddb */
case 0x0ffd: /* paddw */
- case 0x0ffe: /* paddl */
+ case 0x0ffe: /* paddd */
if (i386_record_modrm (&ir))
return -1;
if (!i386_mmx_regnum_p (gdbarch, I387_MM0_REGNUM (tdep) + ir.reg))
if (ir.mod == 3)
{
ir.rm |= ir.rex_b;
- if (!i386_xmm_regnum_p (gdbarch, I387_XMM0_REGNUM (tdep) + ir.rm))
+ if (!i386_xmm_regnum_p (gdbarch,
+ I387_XMM0_REGNUM (tdep) + ir.rm))
goto no_support;
record_arch_list_add_reg (ir.regcache,
I387_XMM0_REGNUM (tdep) + ir.rm);
/* Return a bit of target-specific detail to add to the caller's
generic failure message. */
if (msg)
- *msg = xstrprintf (_("; instruction is only %d bytes long, need at least %d bytes for the jump"),
+ *msg = xstrprintf (_("; instruction is only %d bytes long, "
+ "need at least %d bytes for the jump"),
len, jumplen);
return 0;
}