This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 5/8] Implement unconditional_branch_address method for arm and thumb


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;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]