This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 7/8] Implement unconditional_branch_address method for rl78
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 19 Aug 2015 00:13:53 -0700
- Subject: [PATCH 7/8] Implement unconditional_branch_address method for rl78
- Authentication-results: sourceware.org; auth=none
- References: <20150818235334 dot 1afb0c85 at pinnacle dot lan>
Implement unconditional_branch_address method for rl78.
gdb/ChangeLog:
* rl78-tdep.c (rl78_unconditional_branch_address): New function.
(rl78_gdbarch_init): Register rl78_unconditional_branch_address.
---
gdb/rl78-tdep.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index a5861d8..98129cc 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1365,6 +1365,31 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
return rl78_make_data_address (sp + 4);
}
+/* Implement the unconditional_branch_address gdbarch method. */
+
+static CORE_ADDR
+rl78_unconditional_branch_address (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ int bytes_read;
+ RL78_Opcode_Decoded opc;
+ struct rl78_get_opcode_byte_handle opcode_handle;
+
+ opcode_handle.pc = pc;
+
+ bytes_read = rl78_decode_opcode (pc, &opc, rl78_get_opcode_byte,
+ &opcode_handle);
+
+ if (bytes_read > 0
+ && opc.id == RLO_branch
+ && opc.op[0].type == RL78_Operand_Immediate)
+ {
+ LONGEST l = opc.op[0].addend;
+
+ return (CORE_ADDR) l;
+ }
+
+ return 0;
+}
/* Allocate and initialize a gdbarch object. */
static struct gdbarch *
@@ -1491,6 +1516,10 @@ rl78_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,
+ rl78_unconditional_branch_address);
+
return gdbarch;
}