This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 8/8] Implement unconditional_branch_address method for rx
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 19 Aug 2015 00:15:52 -0700
- Subject: [PATCH 8/8] Implement unconditional_branch_address method for rx
- Authentication-results: sourceware.org; auth=none
- References: <20150818235334 dot 1afb0c85 at pinnacle dot lan>
Implement unconditional_branch_address method for rx.
gdb/ChangeLog:
* rx-tdep.c (rx_unconditional_branch_address): New function.
(rx_gdbarch_init): Register rx_unconditional_branch_address.
---
gdb/rx-tdep.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 0bd91ff..f7ba2fb 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -1015,6 +1015,38 @@ rx_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
reg);
}
+/* Implement the unconditional_branch_address gdbarch method. */
+
+static CORE_ADDR
+rx_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ int bytes_read;
+ RX_Opcode_Decoded opc;
+ struct rx_get_opcode_byte_handle opcode_handle;
+
+ opcode_handle.pc = pc;
+
+ bytes_read = rx_decode_opcode (pc, &opc, rx_get_opcode_byte,
+ &opcode_handle);
+
+ if (bytes_read > 0
+ && (opc.id == RXO_branch || opc.id == RXO_branchrel)
+ && (opc.op[1].type == RX_Operand_None
+ || (opc.op[1].type == RX_Operand_Condition
+ && opc.op[1].reg == RXC_always))
+ && opc.op[0].type == RX_Operand_Immediate)
+ {
+ LONGEST l = opc.op[0].addend;
+
+ if (opc.id == RXO_branch)
+ return (CORE_ADDR) l;
+ else
+ return pc + l;
+ }
+
+ return 0;
+}
+
/* Allocate and initialize a gdbarch object. */
static struct gdbarch *
rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
@@ -1146,6 +1178,10 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Virtual tables. */
set_gdbarch_vbit_in_delta (gdbarch, 1);
+ /* Unconditional Branch. */
+ set_gdbarch_unconditional_branch_address (gdbarch,
+ rx_unconditional_branch_address);
+
return gdbarch;
}