diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-11-03 14:35:13 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-11-03 14:35:13 +0000 |
commit | d19280adb5b2d1470dc39756ccac8a8fa2af8321 (patch) | |
tree | c452ae7ecd2c45f4dfbfe404eb4bd5a7c99aaf28 /gdb/arc-tdep.c | |
parent | 44f1c4d7b0160a51ecf7fe1af42416f1d2a71356 (diff) | |
download | fsf-binutils-gdb-d19280adb5b2d1470dc39756ccac8a8fa2af8321.zip fsf-binutils-gdb-d19280adb5b2d1470dc39756ccac8a8fa2af8321.tar.gz fsf-binutils-gdb-d19280adb5b2d1470dc39756ccac8a8fa2af8321.tar.bz2 |
Split breakpoint_from_pc to breakpoint_kind_from_pc and sw_breakpoint_from_kind
We convert each ARCH_breakpoint_from_pc to ARCH_breakpoint_kind_from_pc
and ARCH_sw_breakpoint_from_kind. Note that gdbarch doesn't have methods
breakpoint_kind_from_pc and sw_breakpoint_from_kind so far.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_FROM_PC): New macro.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): New macro.
* arm-tdep.c (arm_breakpoint_from_pc): Remove.
(arm_breakpoint_kind_from_pc): New function.
(arm_sw_breakpoint_from_kind): New function.
(arm_breakpoint_from_pc): Call arm_breakpoint_kind_from_pc
and arm_sw_breakpoint_from_kind.
Use GDBARCH_BREAKPOINT_FROM_PC.
(arm_remote_breakpoint_from_pc): Call
arm_breakpoint_kind_from_pc.
(arm_gdbarch_init): Replace set_gdbarch_breakpoint_from_pc
with SET_GDBARCH_BREAKPOINT_MANIPULATION.
* arc-tdep.c: Likewise.
* bfin-tdep.c: Likewise.
* cris-tdep.c: Likewise.
* iq2000-tdep.c: Likewise.
* m32r-tdep.c: Likewise.
* mips-tdep.c: Likewise.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* rs6000-tdep.c: Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
Diffstat (limited to 'gdb/arc-tdep.c')
-rw-r--r-- | gdb/arc-tdep.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index c848dc2..fe8d38d 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -715,9 +715,7 @@ static const gdb_byte arc_brk_s_le[] = { 0xff, 0x7f }; static const gdb_byte arc_brk_be[] = { 0x25, 0x6f, 0x00, 0x3f }; static const gdb_byte arc_brk_le[] = { 0x6f, 0x25, 0x3f, 0x00 }; -/* Implement the "breakpoint_from_pc" gdbarch method. - - For ARC ELF, breakpoint uses the 16-bit BRK_S instruction, which is 0x7fff +/* For ARC ELF, breakpoint uses the 16-bit BRK_S instruction, which is 0x7fff (little endian) or 0xff7f (big endian). We used to insert BRK_S even instead of 32-bit instructions, which works mostly ok, unless breakpoint is inserted into delay slot instruction. In this case if branch is taken @@ -734,15 +732,12 @@ static const gdb_byte arc_brk_le[] = { 0x6f, 0x25, 0x3f, 0x00 }; NB: Baremetal GDB uses BRK[_S], while user-space GDB uses TRAP_S. BRK[_S] is much better because it doesn't commit unlike TRAP_S, so it can be set in delay slots; however it cannot be used in user-mode, hence usage of TRAP_S - in GDB for user-space. + in GDB for user-space. */ - PCPTR is a pointer to the PC where we want to place a breakpoint. LENPTR - is a number of bytes used by the breakpoint. Returns the byte sequence of - a breakpoint instruction. */ +/* Implement the "breakpoint_kind_from_pc" gdbarch method. */ -static const gdb_byte * -arc_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, - int *lenptr) +static int +arc_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) { size_t length_with_limm = gdb_insn_length (gdbarch, *pcptr); @@ -751,21 +746,34 @@ arc_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, bytes for 32-bit instructions. */ if ((length_with_limm == 4 || length_with_limm == 8) && !arc_mach_is_arc600 (gdbarch)) + return sizeof (arc_brk_le); + else + return sizeof (arc_brk_s_le); +} + +/* Implement the "sw_breakpoint_from_kind" gdbarch method. */ + +static const gdb_byte * +arc_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) +{ + *size = kind; + + if (kind == sizeof (arc_brk_le)) { - *lenptr = sizeof (arc_brk_le); return ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) ? arc_brk_be : arc_brk_le); } else { - *lenptr = sizeof (arc_brk_s_le); return ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) ? arc_brk_s_be : arc_brk_s_le); } } +GDBARCH_BREAKPOINT_FROM_PC (arc) + /* Implement the "unwind_pc" gdbarch method. */ static CORE_ADDR @@ -1229,7 +1237,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_skip_prologue (gdbarch, arc_skip_prologue); set_gdbarch_inner_than (gdbarch, core_addr_lessthan); - set_gdbarch_breakpoint_from_pc (gdbarch, arc_breakpoint_from_pc); + SET_GDBARCH_BREAKPOINT_MANIPULATION (arc); /* On ARC 600 BRK_S instruction advances PC, unlike other ARC cores. */ if (!arc_mach_is_arc600 (gdbarch)) |