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/arm-tdep.c | |
parent | 44f1c4d7b0160a51ecf7fe1af42416f1d2a71356 (diff) | |
download | gdb-d19280adb5b2d1470dc39756ccac8a8fa2af8321.zip gdb-d19280adb5b2d1470dc39756ccac8a8fa2af8321.tar.gz 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/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 645825f..183c365 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -7843,16 +7843,8 @@ static const gdb_byte arm_default_arm_be_breakpoint[] = ARM_BE_BREAKPOINT; static const gdb_byte arm_default_thumb_le_breakpoint[] = THUMB_LE_BREAKPOINT; static const gdb_byte arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT; -/* Determine the type and size of breakpoint to insert at PCPTR. Uses - the program counter value to determine whether a 16-bit or 32-bit - breakpoint should be used. It returns a pointer to a string of - bytes that encode a breakpoint instruction, stores the length of - the string to *lenptr, and adjusts the program counter (if - necessary) to point to the actual memory location where the - breakpoint should be inserted. */ - -static const unsigned char * -arm_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr) +static int +arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); @@ -7866,38 +7858,61 @@ arm_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr) if (tdep->thumb2_breakpoint != NULL) { gdb_byte buf[2]; + if (target_read_memory (*pcptr, buf, 2) == 0) { unsigned short inst1; + inst1 = extract_unsigned_integer (buf, 2, byte_order_for_code); if (thumb_insn_size (inst1) == 4) - { - *lenptr = tdep->thumb2_breakpoint_size; - return tdep->thumb2_breakpoint; - } + return ARM_BP_KIND_THUMB2; } } - *lenptr = tdep->thumb_breakpoint_size; - return tdep->thumb_breakpoint; + return ARM_BP_KIND_THUMB; } else + return ARM_BP_KIND_ARM; + +} + +static const gdb_byte * +arm_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + switch (kind) { - *lenptr = tdep->arm_breakpoint_size; + case ARM_BP_KIND_ARM: + *size = tdep->arm_breakpoint_size; return tdep->arm_breakpoint; + case ARM_BP_KIND_THUMB: + *size = tdep->thumb_breakpoint_size; + return tdep->thumb_breakpoint; + case ARM_BP_KIND_THUMB2: + *size = tdep->thumb2_breakpoint_size; + return tdep->thumb2_breakpoint; + default: + gdb_assert_not_reached ("unexpected arm breakpoint kind"); } } +/* Determine the type and size of breakpoint to insert at PCPTR. Uses + the program counter value to determine whether a 16-bit or 32-bit + breakpoint should be used. It returns a pointer to a string of + bytes that encode a breakpoint instruction, stores the length of + the string to *lenptr, and adjusts the program counter (if + necessary) to point to the actual memory location where the + breakpoint should be inserted. */ + +GDBARCH_BREAKPOINT_FROM_PC (arm) + static void arm_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr) { - arm_breakpoint_from_pc (gdbarch, pcptr, kindptr); - if (arm_pc_is_thumb (gdbarch, *pcptr) && *kindptr == 4) - /* The documented magic value for a 32-bit Thumb-2 breakpoint, so - that this is not confused with a 32-bit ARM breakpoint. */ - *kindptr = ARM_BP_KIND_THUMB2; + *kindptr = arm_breakpoint_kind_from_pc (gdbarch, pcptr); } /* Extract from an array REGBUF containing the (raw) register state a @@ -9407,7 +9422,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_inner_than (gdbarch, core_addr_lessthan); /* Breakpoint manipulation. */ - set_gdbarch_breakpoint_from_pc (gdbarch, arm_breakpoint_from_pc); + SET_GDBARCH_BREAKPOINT_MANIPULATION (arm); set_gdbarch_remote_breakpoint_from_pc (gdbarch, arm_remote_breakpoint_from_pc); |