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 6/8] Implement unconditional_branch_address method for powerpc / rs6000


Implement unconditional_branch_address method for powerpc / rs6000.

gdb/ChangeLog:
    
    	* rs6000-tdep.c (rs6000_unconditional_branch_address): New function.
    	(rs6000_gdbarch_init): Register rs6000_unconditional_branch_address.
---
 gdb/rs6000-tdep.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 785f451..f1c33e0 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -3578,6 +3578,20 @@ ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
     reg->how = DWARF2_FRAME_REG_CFA;
 }
 
+/* Implement the unconditional_branch_address gdbarch method.  */
+
+static CORE_ADDR
+rs6000_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  unsigned long insn = read_memory_unsigned_integer (pc, 4, byte_order);
+
+  if ((insn & 0xfc000003) == 0x48000000)	/* b instruction.  */
+    return pc + (((insn & 0x02000000) ? ~((CORE_ADDR) 0x03fffffc) : 0)
+                   | (insn & 0x03fffffc));
+  else
+    return 0;
+}
 
 /* Return true if a .gnu_attributes section exists in BFD and it
    indicates we are using SPE extensions OR if a .PPC.EMB.apuinfo
@@ -6051,6 +6065,10 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   else
     register_ppc_ravenscar_ops (gdbarch);
 
+  /* Unconditional Branch.  */
+  set_gdbarch_unconditional_branch_address
+    (gdbarch, rs6000_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]