This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 5/8] Implement unconditional_branch_address method for arm and thumb
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 19 Aug 2015 00:08:44 -0700
- Subject: [PATCH 5/8] Implement unconditional_branch_address method for arm and thumb
- Authentication-results: sourceware.org; auth=none
- References: <20150818235334 dot 1afb0c85 at pinnacle dot lan>
Implement unconditional_branch_address method for arm and thumb.
gdb/ChangeLog:
* arm-tdep.c (arm_unconditional_branch_address): New function.
(arm_gdbarch_init): Register arm_unconditional_branch_address.
---
gdb/arm-tdep.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 73f26b9..2e16a28 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9902,7 +9902,32 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch)
/* Otherwise we don't have a useful guess. */
}
+
+/* Implement the unconditional_branch_address gdbarch method. */
+
+static CORE_ADDR
+arm_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
+ unsigned int insn;
+
+ if (arm_pc_is_thumb (gdbarch, pc))
+ {
+ insn = read_memory_unsigned_integer (pc, 2, byte_order_for_code);
+ if ((insn & 0xf800) == 0xe000)
+ return pc + 4 + (sbits (insn, 0, 10) << 1);
+ }
+ else
+ {
+ insn = read_memory_unsigned_integer (pc, 4, byte_order_for_code);
+
+ if (bits (insn, 28, 31) == INST_AL && bits (insn, 24, 27) == 0xa)
+ return BranchDest (pc, insn);
+ }
+
+ return 0;
+}
/* Initialize the current architecture based on INFO. If possible,
re-use an architecture from ARCHES, which is a list of
@@ -10499,6 +10524,10 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
user_reg_add (gdbarch, arm_register_aliases[i].name,
value_of_arm_user_reg, &arm_register_aliases[i].regnum);
+ /* Unconditional Branch. */
+ set_gdbarch_unconditional_branch_address (gdbarch,
+ arm_unconditional_branch_address);
+
return gdbarch;
}