/* Target-dependent code for the Matsushita MN10300 for GDB, the GNU debugger.
- Copyright (C) 1996-2015 Free Software Foundation, Inc.
+ Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of GDB.
/* The am33-2 has 64 registers. */
#define MN10300_MAX_NUM_REGS 64
+/* Big enough to hold the size of the largest register in bytes. */
+#define MN10300_MAX_REGISTER_SIZE 64
+
/* This structure holds the results of a prologue analysis. */
struct mn10300_prologue
{
case TYPE_CODE_FLT:
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
+ case TYPE_CODE_RVALUE_REF:
return TYPE_LENGTH (type);
case TYPE_CODE_COMPLEX:
mn10300_extract_return_value (struct gdbarch *gdbarch, struct type *type,
struct regcache *regcache, void *valbuf)
{
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[MN10300_MAX_REGISTER_SIZE];
int len = TYPE_LENGTH (type);
int reg, regsz;
reg = 0;
regsz = register_size (gdbarch, reg);
+ gdb_assert (regsz <= MN10300_MAX_REGISTER_SIZE);
if (len <= regsz)
{
regcache_raw_read (regcache, reg, buf);
return RETURN_VALUE_REGISTER_CONVENTION;
}
-static char *
-register_name (int reg, char **regs, long sizeof_regs)
+static const char *
+register_name (int reg, const char **regs, long sizeof_regs)
{
if (reg < 0 || reg >= sizeof_regs / sizeof (regs[0]))
return NULL;
static const char *
mn10300_generic_register_name (struct gdbarch *gdbarch, int reg)
{
- static char *regs[] =
+ static const char *regs[] =
{ "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
"sp", "pc", "mdr", "psw", "lir", "lar", "", "",
"", "", "", "", "", "", "", "",
static const char *
am33_register_name (struct gdbarch *gdbarch, int reg)
{
- static char *regs[] =
+ static const char *regs[] =
{ "d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
"sp", "pc", "mdr", "psw", "lir", "lar", "",
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
static const char *
am33_2_register_name (struct gdbarch *gdbarch, int reg)
{
- static char *regs[] =
+ static const char *regs[] =
{
"d0", "d1", "d2", "d3", "a0", "a1", "a2", "a3",
"sp", "pc", "mdr", "psw", "lir", "lar", "mdrq", "r0",
The Matsushita mn10x00 processors have single byte instructions
so we need a single byte breakpoint. Matsushita hasn't defined
one, so we defined it ourselves. */
+constexpr gdb_byte mn10300_break_insn[] = {0xff};
-static const unsigned char *
-mn10300_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
- int *bp_size)
-{
- static gdb_byte breakpoint[] = {0xff};
- *bp_size = 1;
- return breakpoint;
-}
+typedef BP_MANIPULATION (mn10300_break_insn) mn10300_breakpoint;
/* Model the semantics of pushing a register onto the stack. This
is a helper function for mn10300_analyze_prologue, below. */
mn10300_frame_prev_register (struct frame_info *this_frame,
void **this_prologue_cache, int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
struct mn10300_prologue *p
= mn10300_analyze_frame_prologue (this_frame, this_prologue_cache);
CORE_ADDR frame_base = mn10300_frame_base (this_frame, this_prologue_cache);
- int reg_size = register_size (get_frame_arch (this_frame), regnum);
if (regnum == E_SP_REGNUM)
return frame_unwind_got_constant (this_frame, regnum, frame_base);
int stack_offset = 0;
int argnum;
const gdb_byte *val;
- gdb_byte valbuf[MAX_REGISTER_SIZE];
+ gdb_byte valbuf[MN10300_MAX_REGISTER_SIZE];
/* This should be a nop, but align the stack just in case something
went wrong. Stacks are four byte aligned on the mn10300. */
{
/* Change to pointer-to-type. */
arg_len = push_size;
+ gdb_assert (push_size <= MN10300_MAX_REGISTER_SIZE);
store_unsigned_integer (valbuf, push_size, byte_order,
value_address (*args));
val = &valbuf[0];
if (arches != NULL)
return arches->gdbarch;
- tdep = XNEW (struct gdbarch_tdep);
+ tdep = XCNEW (struct gdbarch_tdep);
gdbarch = gdbarch_alloc (&info, tdep);
switch (info.bfd_arch_info->mach)
/* Stack unwinding. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
/* Breakpoints. */
- set_gdbarch_breakpoint_from_pc (gdbarch, mn10300_breakpoint_from_pc);
+ set_gdbarch_breakpoint_kind_from_pc (gdbarch,
+ mn10300_breakpoint::kind_from_pc);
+ set_gdbarch_sw_breakpoint_from_kind (gdbarch,
+ mn10300_breakpoint::bp_from_kind);
/* decr_pc_after_break? */
- /* Disassembly. */
- set_gdbarch_print_insn (gdbarch, print_insn_mn10300);
/* Stage 2 */
set_gdbarch_return_value (gdbarch, mn10300_return_value);