Index: mips-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mips-tdep.c,v retrieving revision 1.539 diff -u -p -r1.539 mips-tdep.c --- mips-tdep.c 10 Apr 2012 23:06:57 -0000 1.539 +++ mips-tdep.c 20 Apr 2012 18:50:40 -0000 @@ -1162,6 +1162,32 @@ mips32_bc1_pc (struct gdbarch *gdbarch, return pc; } +/* Return nonzero if the gdbarch is an Octeon series. */ +static int +is_octeon (struct gdbarch *gdbarch) +{ + const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch); + + return (info->mach == bfd_mach_mips_octeon + || info->mach == bfd_mach_mips_octeonp + || info->mach == bfd_mach_mips_octeon2); +} + +/* Return true if the OP represents the Octeon's BBIT instruction. */ +static int +is_octeon_bbit_op (int op, struct gdbarch *gdbarch) +{ + if (!is_octeon (gdbarch)) + return 0; + /* BBIT0 is encoded as LWC2: 110 010. */ + /* BBIT032 is encoded as LDC2: 110 110. */ + /* BBIT1 is encoded as SWC2: 111 010. */ + /* BBIT132 is encoded as SDC2: 111 110. */ + if (op == 50 || op == 54 || op == 58 || op == 62) + return 1; + return 0; +} + /* Determine where to set a single step breakpoint while considering branch prediction. */ static CORE_ADDR @@ -1174,7 +1200,8 @@ mips32_next_pc (struct frame_info *frame if ((inst & 0xe0000000) != 0) /* Not a special, jump or branch instruction. */ { - if (itype_op (inst) >> 2 == 5) + op = itype_op (inst); + if (op >> 2 == 5) /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */ { op = (itype_op (inst) & 0x03); @@ -1192,18 +1219,18 @@ mips32_next_pc (struct frame_info *frame pc += 4; } } - else if (itype_op (inst) == 17 && itype_rs (inst) == 8) + else if (op == 17 && itype_rs (inst) == 8) /* BC1F, BC1FL, BC1T, BC1TL: 010001 01000 */ pc = mips32_bc1_pc (gdbarch, frame, inst, pc + 4, 1); - else if (itype_op (inst) == 17 && itype_rs (inst) == 9 + else if (op == 17 && itype_rs (inst) == 9 && (itype_rt (inst) & 2) == 0) /* BC1ANY2F, BC1ANY2T: 010001 01001 xxx0x */ pc = mips32_bc1_pc (gdbarch, frame, inst, pc + 4, 2); - else if (itype_op (inst) == 17 && itype_rs (inst) == 10 + else if (op == 17 && itype_rs (inst) == 10 && (itype_rt (inst) & 2) == 0) /* BC1ANY4F, BC1ANY4T: 010001 01010 xxx0x */ pc = mips32_bc1_pc (gdbarch, frame, inst, pc + 4, 4); - else if (itype_op (inst) == 29) + else if (op == 29) /* JALX: 011101 */ /* The new PC will be alternate mode. */ { @@ -1213,6 +1240,21 @@ mips32_next_pc (struct frame_info *frame /* Add 1 to indicate 16-bit mode -- invert ISA mode. */ pc = ((pc + 4) & ~(CORE_ADDR) 0x0fffffff) + reg + 1; } + else if (is_octeon_bbit_op (op, gdbarch)) + { + int bit, branch_if; + + branch_if = op == 58 || op == 62; + bit = itype_rt (inst); + if (op == 54 || op == 62) + bit += 32; + if (((get_frame_register_signed (frame, + itype_rs (inst)) >> bit) & 1) + == branch_if) + pc += mips32_relative_offset (inst) + 4; + else + pc += 8; /* After the delay slot. */ + } else pc += 4; /* Not a branch, next instruction is easy. */ } @@ -5399,7 +5441,8 @@ mips32_instruction_has_delay_slot (struc { rs = itype_rs (inst); rt = itype_rt (inst); - return (op >> 2 == 5 /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */ + return (is_octeon_bbit_op (op, gdbarch) + || op >> 2 == 5 /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */ || op == 29 /* JALX: bits 011101 */ || (op == 17 && (rs == 8