/* Target-dependent code for the Renesas RL78 for GDB, the GNU debugger.
- Copyright (C) 2011-2019 Free Software Foundation, Inc.
+ Copyright (C) 2011-2021 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
#include "frame-base.h"
#include "value.h"
#include "gdbcore.h"
-#include "dwarf2-frame.h"
+#include "dwarf2/frame.h"
#include "reggroups.h"
#include "elf/rl78.h"
int elf_flags;
struct type *rl78_void,
- *rl78_uint8,
+ *rl78_uint8,
*rl78_int8,
*rl78_uint16,
*rl78_int16,
else if (reg_nr == RL78_PSW_REGNUM)
return rl78_psw_type (gdbarch);
else if (reg_nr <= RL78_MEM_REGNUM
- || (RL78_X_REGNUM <= reg_nr && reg_nr <= RL78_H_REGNUM)
+ || (RL78_X_REGNUM <= reg_nr && reg_nr <= RL78_H_REGNUM)
|| (RL78_BANK0_R0_REGNUM <= reg_nr
&& reg_nr <= RL78_BANK3_R7_REGNUM))
return tdep->rl78_int8;
else if (reg_nr == RL78_SP_REGNUM
- || (RL78_BANK0_RP0_PTR_REGNUM <= reg_nr
+ || (RL78_BANK0_RP0_PTR_REGNUM <= reg_nr
&& reg_nr <= RL78_BANK3_RP3_PTR_REGNUM))
return tdep->rl78_data_pointer;
else
static enum register_status
rl78_pseudo_register_read (struct gdbarch *gdbarch,
readable_regcache *regcache,
- int reg, gdb_byte *buffer)
+ int reg, gdb_byte *buffer)
{
enum register_status status;
if (RL78_BANK0_R0_REGNUM <= reg && reg <= RL78_BANK3_R7_REGNUM)
{
int raw_regnum = RL78_RAW_BANK0_R0_REGNUM
- + (reg - RL78_BANK0_R0_REGNUM);
+ + (reg - RL78_BANK0_R0_REGNUM);
status = regcache->raw_read (raw_regnum, buffer);
}
else if (RL78_BANK0_RP0_REGNUM <= reg && reg <= RL78_BANK3_RP3_REGNUM)
{
int raw_regnum = 2 * (reg - RL78_BANK0_RP0_REGNUM)
- + RL78_RAW_BANK0_R0_REGNUM;
+ + RL78_RAW_BANK0_R0_REGNUM;
status = regcache->raw_read (raw_regnum, buffer);
if (status == REG_VALID)
else if (RL78_BANK0_RP0_PTR_REGNUM <= reg && reg <= RL78_BANK3_RP3_PTR_REGNUM)
{
int raw_regnum = 2 * (reg - RL78_BANK0_RP0_PTR_REGNUM)
- + RL78_RAW_BANK0_R0_REGNUM;
+ + RL78_RAW_BANK0_R0_REGNUM;
status = regcache->raw_read (raw_regnum, buffer);
if (status == REG_VALID)
/* RSB0 is at bit 3; RSBS1 is at bit 5. */
int bank = ((psw >> 3) & 1) | ((psw >> 4) & 1);
int raw_regnum = RL78_RAW_BANK0_R0_REGNUM + bank * RL78_REGS_PER_BANK
- + (reg - RL78_X_REGNUM);
+ + (reg - RL78_X_REGNUM);
status = regcache->raw_read (raw_regnum, buffer);
}
}
/* RSB0 is at bit 3; RSBS1 is at bit 5. */
int bank = ((psw >> 3) & 1) | ((psw >> 4) & 1);
int raw_regnum = RL78_RAW_BANK0_R0_REGNUM + bank * RL78_REGS_PER_BANK
- + 2 * (reg - RL78_AX_REGNUM);
+ + 2 * (reg - RL78_AX_REGNUM);
status = regcache->raw_read (raw_regnum, buffer);
if (status == REG_VALID)
status = regcache->raw_read (raw_regnum + 1, buffer + 1);
static void
rl78_pseudo_register_write (struct gdbarch *gdbarch,
- struct regcache *regcache,
- int reg, const gdb_byte *buffer)
+ struct regcache *regcache,
+ int reg, const gdb_byte *buffer)
{
if (RL78_BANK0_R0_REGNUM <= reg && reg <= RL78_BANK3_R7_REGNUM)
{
int raw_regnum = RL78_RAW_BANK0_R0_REGNUM
- + (reg - RL78_BANK0_R0_REGNUM);
+ + (reg - RL78_BANK0_R0_REGNUM);
regcache->raw_write (raw_regnum, buffer);
}
else if (RL78_BANK0_RP0_REGNUM <= reg && reg <= RL78_BANK3_RP3_REGNUM)
{
int raw_regnum = 2 * (reg - RL78_BANK0_RP0_REGNUM)
- + RL78_RAW_BANK0_R0_REGNUM;
+ + RL78_RAW_BANK0_R0_REGNUM;
regcache->raw_write (raw_regnum, buffer);
regcache->raw_write (raw_regnum + 1, buffer + 1);
else if (RL78_BANK0_RP0_PTR_REGNUM <= reg && reg <= RL78_BANK3_RP3_PTR_REGNUM)
{
int raw_regnum = 2 * (reg - RL78_BANK0_RP0_PTR_REGNUM)
- + RL78_RAW_BANK0_R0_REGNUM;
+ + RL78_RAW_BANK0_R0_REGNUM;
regcache->raw_write (raw_regnum, buffer);
regcache->raw_write (raw_regnum + 1, buffer + 1);
bank = ((psw >> 3) & 1) | ((psw >> 4) & 1);
/* RSB0 is at bit 3; RSBS1 is at bit 5. */
raw_regnum = RL78_RAW_BANK0_R0_REGNUM + bank * RL78_REGS_PER_BANK
- + (reg - RL78_X_REGNUM);
+ + (reg - RL78_X_REGNUM);
regcache->raw_write (raw_regnum, buffer);
}
else if (RL78_AX_REGNUM <= reg && reg <= RL78_HL_REGNUM)
switch (opcreg)
{
case RL78_Reg_X:
- return RL78_X_REGNUM;
+ return RL78_X_REGNUM;
case RL78_Reg_A:
return RL78_A_REGNUM;
case RL78_Reg_C:
static void
check_for_saved (void *result_untyped, pv_t addr, CORE_ADDR size,
- pv_t value)
+ pv_t value)
{
struct rl78_prologue *result = (struct rl78_prologue *) result_untyped;
bank = opc.op[1].addend;
}
else if (opc.id == RLO_mov
- && opc.op[0].type == RL78_Operand_PreDec
- && opc.op[0].reg == RL78_Reg_SP
+ && opc.op[0].type == RL78_Operand_PreDec
+ && opc.op[0].reg == RL78_Reg_SP
&& opc.op[1].type == RL78_Operand_Register)
{
int rsrc = (bank * RL78_REGS_PER_BANK)
after_last_frame_setup_insn = next_pc;
}
else if (opc.id == RLO_sub
- && opc.op[0].type == RL78_Operand_Register
+ && opc.op[0].type == RL78_Operand_Register
&& opc.op[0].reg == RL78_Reg_SP
&& opc.op[1].type == RL78_Operand_Immediate)
{
int addend = opc.op[1].addend;
reg[RL78_SP_REGNUM] = pv_add_constant (reg[RL78_SP_REGNUM],
- -addend);
+ -addend);
after_last_frame_setup_insn = next_pc;
}
else if (opc.id == RLO_mov
- && opc.size == RL78_Word
+ && opc.size == RL78_Word
&& opc.op[0].type == RL78_Operand_Register
&& opc.op[1].type == RL78_Operand_Indirect
&& opc.op[1].addend == RL78_SP_ADDR)
= reg[RL78_SP_REGNUM];
}
else if (opc.id == RLO_sub
- && opc.size == RL78_Word
+ && opc.size == RL78_Word
&& opc.op[0].type == RL78_Operand_Register
&& opc.op[1].type == RL78_Operand_Immediate)
{
reg[regnum] = pv_add_constant (reg[regnum], -addend);
}
else if (opc.id == RLO_mov
- && opc.size == RL78_Word
+ && opc.size == RL78_Word
&& opc.op[0].type == RL78_Operand_Indirect
&& opc.op[0].addend == RL78_SP_ADDR
&& opc.op[1].type == RL78_Operand_Register)
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
- addr & 0xffffff);
+ addr & 0xffffff);
}
/* Implement the "pointer_to_address" gdbarch method. */
static CORE_ADDR
rl78_pointer_to_address (struct gdbarch *gdbarch,
- struct type *type, const gdb_byte *buf)
+ struct type *type, const gdb_byte *buf)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR addr
= extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
/* Is it a code address? */
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD
+ if (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_FUNC
+ || TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_METHOD
|| TYPE_CODE_SPACE (TYPE_TARGET_TYPE (type))
|| TYPE_LENGTH (type) == 4)
return rl78_make_instruction_address (addr);
rl78_unwind_pc (struct gdbarch *arch, struct frame_info *next_frame)
{
return rl78_addr_bits_remove
- (arch, frame_unwind_register_unsigned (next_frame,
- RL78_PC_REGNUM));
+ (arch, frame_unwind_register_unsigned (next_frame,
+ RL78_PC_REGNUM));
}
/* Given a frame described by THIS_FRAME, decode the prologue of its
stop_addr = get_frame_pc (this_frame);
/* If we couldn't find any function containing the PC, then
- just initialize the prologue cache, but don't do anything. */
+ just initialize the prologue cache, but don't do anything. */
if (!func_start)
stop_addr = func_start;
void **this_prologue_cache, struct frame_id *this_id)
{
*this_id = frame_id_build (rl78_frame_base (this_frame,
- this_prologue_cache),
+ this_prologue_cache),
get_frame_func (this_frame));
}
static struct value *
rl78_prev_register (struct frame_info *this_frame,
- void **this_prologue_cache, int regnum)
+ void **this_prologue_cache, int regnum)
{
struct rl78_prologue *p
= rl78_analyze_frame_prologue (this_frame, this_prologue_cache);
else if (regnum == RL78_SPL_REGNUM)
return frame_unwind_got_constant (this_frame, regnum,
- (frame_base & 0xff));
+ (frame_base & 0xff));
else if (regnum == RL78_SPH_REGNUM)
return frame_unwind_got_constant (this_frame, regnum,
- ((frame_base >> 8) & 0xff));
+ ((frame_base >> 8) & 0xff));
/* If prologue analysis says we saved this register somewhere,
return a description of the stack slot holding it. */
else if (p->reg_offset[regnum] != 1)
{
struct value *rv =
- frame_unwind_got_memory (this_frame, regnum,
+ frame_unwind_got_memory (this_frame, regnum,
frame_base + p->reg_offset[regnum]);
if (regnum == RL78_PC_REGNUM)
if (0 <= reg && reg <= 31)
{
if ((reg & 1) == 0)
- /* Map even registers to their 16-bit counterparts which have a
+ /* Map even registers to their 16-bit counterparts which have a
pointer type. This is usually what is required from the DWARF
info. */
return (reg >> 1) + RL78_BANK0_RP0_PTR_REGNUM;
{
if (is_g10)
u = read_memory_integer (g10_raddr, 1,
- gdbarch_byte_order (gdbarch));
+ gdbarch_byte_order (gdbarch));
else
regcache_cooked_read_unsigned (regcache, argreg, &u);
store_unsigned_integer (readbuf + offset, 1, byte_order, u);
{
return
frame_id_build (rl78_make_data_address
- (get_frame_register_unsigned
- (this_frame, RL78_SP_REGNUM)),
+ (get_frame_register_unsigned
+ (this_frame, RL78_SP_REGNUM)),
get_frame_pc (this_frame));
}
sp -= container_len;
write_memory (rl78_make_data_address (sp),
- value_contents_all (args[i]), len);
+ value_contents_all (args[i]), len);
}
/* Store struct value address. */
/* Register the above initialization routine. */
+void _initialize_rl78_tdep ();
void
-_initialize_rl78_tdep (void)
+_initialize_rl78_tdep ()
{
register_gdbarch_init (bfd_arch_rl78, rl78_gdbarch_init);
}