[7/8] Implement unconditional_branch_address method for rl78
Commit Message
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(+)
@@ -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;
}