aboutsummaryrefslogtreecommitdiff
path: root/gdb/m32c-tdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/m32c-tdep.c')
-rw-r--r--gdb/m32c-tdep.c113
1 files changed, 67 insertions, 46 deletions
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 3374b00..200d51a 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -95,42 +95,44 @@ struct m32c_reg
#define M32C_MAX_DWARF_REGNUM (40)
-struct gdbarch_tdep
+struct m32c_gdbarch_tdep : gdbarch_tdep
{
/* All the registers for this variant, indexed by GDB register
number, and the number of registers present. */
- struct m32c_reg regs[M32C_MAX_NUM_REGS];
+ struct m32c_reg regs[M32C_MAX_NUM_REGS] {};
/* The number of valid registers. */
- int num_regs;
+ int num_regs = 0;
/* Interesting registers. These are pointers into REGS. */
- struct m32c_reg *pc, *flg;
- struct m32c_reg *r0, *r1, *r2, *r3, *a0, *a1;
- struct m32c_reg *r2r0, *r3r2r1r0, *r3r1r2r0;
- struct m32c_reg *sb, *fb, *sp;
+ struct m32c_reg *pc = nullptr, *flg = nullptr;
+ struct m32c_reg *r0 = nullptr, *r1 = nullptr, *r2 = nullptr, *r3 = nullptr,
+ *a0 = nullptr, *a1 = nullptr;
+ struct m32c_reg *r2r0 = nullptr, *r3r2r1r0 = nullptr, *r3r1r2r0 = nullptr;
+ struct m32c_reg *sb = nullptr, *fb = nullptr, *sp = nullptr;
/* A table indexed by DWARF register numbers, pointing into
REGS. */
- struct m32c_reg *dwarf_regs[M32C_MAX_DWARF_REGNUM + 1];
+ struct m32c_reg *dwarf_regs[M32C_MAX_DWARF_REGNUM + 1] {};
/* Types for this architecture. We can't use the builtin_type_foo
types, because they're not initialized when building a gdbarch
structure. */
- struct type *voyd, *ptr_voyd, *func_voyd;
- struct type *uint8, *uint16;
- struct type *int8, *int16, *int32, *int64;
+ struct type *voyd = nullptr, *ptr_voyd = nullptr, *func_voyd = nullptr;
+ struct type *uint8 = nullptr, *uint16 = nullptr;
+ struct type *int8 = nullptr, *int16 = nullptr, *int32 = nullptr,
+ *int64 = nullptr;
/* The types for data address and code address registers. */
- struct type *data_addr_reg_type, *code_addr_reg_type;
+ struct type *data_addr_reg_type = nullptr, *code_addr_reg_type = nullptr;
/* The number of bytes a return address pushed by a 'jsr' instruction
occupies on the stack. */
- int ret_addr_bytes;
+ int ret_addr_bytes = 0;
/* The number of bytes an address register occupies on the stack
when saved by an 'enter' or 'pushm' instruction. */
- int push_addr_bytes;
+ int push_addr_bytes = 0;
};
@@ -139,7 +141,7 @@ struct gdbarch_tdep
static void
make_types (struct gdbarch *arch)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
unsigned long mach = gdbarch_bfd_arch_info (arch)->mach;
int data_addr_reg_bits, code_addr_reg_bits;
char type_name[50];
@@ -212,28 +214,31 @@ make_types (struct gdbarch *arch)
static const char *
m32c_register_name (struct gdbarch *gdbarch, int num)
{
- return gdbarch_tdep (gdbarch)->regs[num].name;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ return tdep->regs[num].name;
}
static struct type *
m32c_register_type (struct gdbarch *arch, int reg_nr)
{
- return gdbarch_tdep (arch)->regs[reg_nr].type;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
+ return tdep->regs[reg_nr].type;
}
static int
m32c_register_sim_regno (struct gdbarch *gdbarch, int reg_nr)
{
- return gdbarch_tdep (gdbarch)->regs[reg_nr].sim_num;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
+ return tdep->regs[reg_nr].sim_num;
}
static int
m32c_debug_info_reg_to_regnum (struct gdbarch *gdbarch, int reg_nr)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
if (0 <= reg_nr && reg_nr <= M32C_MAX_DWARF_REGNUM
&& tdep->dwarf_regs[reg_nr])
return tdep->dwarf_regs[reg_nr]->num;
@@ -248,7 +253,7 @@ static int
m32c_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
struct reggroup *group)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
struct m32c_reg *reg = &tdep->regs[regnum];
/* The anonymous raw registers aren't in any groups. */
@@ -323,7 +328,8 @@ m32c_raw_write (struct m32c_reg *reg, struct regcache *cache,
static int
m32c_read_flg (readable_regcache *cache)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (cache->arch ());
+ gdbarch *arch = cache->arch ();
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
ULONGEST flg;
cache->raw_read (tdep->flg->num, &flg);
@@ -522,7 +528,8 @@ m32c_cat_write (struct m32c_reg *reg, struct regcache *cache,
static enum register_status
m32c_r3r2r1r0_read (struct m32c_reg *reg, readable_regcache *cache, gdb_byte *buf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
+ gdbarch *arch = reg->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
int len = TYPE_LENGTH (tdep->r0->type);
enum register_status status;
@@ -558,7 +565,8 @@ static enum register_status
m32c_r3r2r1r0_write (struct m32c_reg *reg, struct regcache *cache,
const gdb_byte *buf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (reg->arch);
+ gdbarch *arch = reg->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
int len = TYPE_LENGTH (tdep->r0->type);
if (gdbarch_byte_order (reg->arch) == BFD_ENDIAN_BIG)
@@ -586,7 +594,7 @@ m32c_pseudo_register_read (struct gdbarch *arch,
int cookednum,
gdb_byte *buf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
struct m32c_reg *reg;
gdb_assert (0 <= cookednum && cookednum < tdep->num_regs);
@@ -604,7 +612,7 @@ m32c_pseudo_register_write (struct gdbarch *arch,
int cookednum,
const gdb_byte *buf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
struct m32c_reg *reg;
gdb_assert (0 <= cookednum && cookednum < tdep->num_regs);
@@ -629,7 +637,7 @@ add_reg (struct gdbarch *arch,
struct m32c_reg *ry,
int n)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
struct m32c_reg *r = &tdep->regs[tdep->num_regs];
gdb_assert (tdep->num_regs < M32C_MAX_NUM_REGS);
@@ -668,7 +676,9 @@ set_dwarf_regnum (struct m32c_reg *reg, int num)
reg->dwarf_num = num;
/* Update the DWARF->reg mapping. */
- gdbarch_tdep (reg->arch)->dwarf_regs[num] = reg;
+ gdbarch *arch = reg->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
+ tdep->dwarf_regs[num] = reg;
}
@@ -789,7 +799,7 @@ mark_save_restore (struct m32c_reg *reg)
static void
make_regs (struct gdbarch *arch)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
int mach = gdbarch_bfd_arch_info (arch)->mach;
int num_raw_regs;
int num_cooked_regs;
@@ -1336,16 +1346,17 @@ m32c_decode_sd23 (struct m32c_pv_state *st, int code, int size, int ind)
static int
m32c_pv_enter (struct m32c_pv_state *state, int size)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (state->arch);
-
/* If simulating this store would require us to forget
everything we know about the stack frame in the name of
accuracy, it would be better to just quit now. */
if (state->stack->store_would_trash (state->sp))
return 1;
+ gdbarch *arch = state->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
if (m32c_pv_push (state, state->fb, tdep->push_addr_bytes))
return 1;
+
state->fb = state->sp;
state->sp = pv_add_constant (state->sp, -size);
@@ -1371,7 +1382,8 @@ m32c_pv_pushm_one (struct m32c_pv_state *state, pv_t reg,
static int
m32c_pv_pushm (struct m32c_pv_state *state, int src)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (state->arch);
+ gdbarch *arch = state->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
/* The bits in SRC indicating which registers to save are:
r0 r1 r2 r3 a0 a1 sb fb */
@@ -1391,7 +1403,9 @@ m32c_pv_pushm (struct m32c_pv_state *state, int src)
static int
m32c_is_1st_arg_reg (struct m32c_pv_state *state, pv_t value)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (state->arch);
+ gdbarch *arch = state->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
+
return (value.kind == pvk_register
&& (gdbarch_bfd_arch_info (state->arch)->mach == bfd_mach_m16c
? (value.reg == tdep->r1->num)
@@ -1404,7 +1418,9 @@ m32c_is_1st_arg_reg (struct m32c_pv_state *state, pv_t value)
static int
m32c_is_arg_reg (struct m32c_pv_state *state, pv_t value)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (state->arch);
+ gdbarch *arch = state->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
+
return (value.kind == pvk_register
&& (gdbarch_bfd_arch_info (state->arch)->mach == bfd_mach_m16c
? (value.reg == tdep->r1->num || value.reg == tdep->r2->num)
@@ -1427,7 +1443,8 @@ m32c_is_arg_spill (struct m32c_pv_state *st,
struct srcdest loc,
pv_t value)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (st->arch);
+ gdbarch *arch = st->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
return (m32c_is_arg_reg (st, value)
&& loc.kind == srcdest_mem
@@ -1450,7 +1467,8 @@ m32c_is_struct_return (struct m32c_pv_state *st,
struct srcdest loc,
pv_t value)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (st->arch);
+ gdbarch *arch = st->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
return (m32c_is_1st_arg_reg (st, value)
&& !st->stack->find_reg (st->arch, value.reg, 0)
@@ -1467,7 +1485,9 @@ m32c_is_struct_return (struct m32c_pv_state *st,
static int
m32c_pushm_is_reg_save (struct m32c_pv_state *st, int src)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (st->arch);
+ gdbarch *arch = st->arch;
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
+
/* The bits in SRC indicating which registers to save are:
r0 r1 r2 r3 a0 a1 sb fb */
return
@@ -1494,7 +1514,7 @@ check_for_saved (void *prologue_untyped, pv_t addr, CORE_ADDR size, pv_t value)
{
struct m32c_prologue *prologue = (struct m32c_prologue *) prologue_untyped;
struct gdbarch *arch = prologue->arch;
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
/* Is this the unchanged value of some register being saved on the
stack? */
@@ -1534,7 +1554,7 @@ m32c_analyze_prologue (struct gdbarch *arch,
CORE_ADDR start, CORE_ADDR limit,
struct m32c_prologue *prologue)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
unsigned long mach = gdbarch_bfd_arch_info (arch)->mach;
CORE_ADDR after_last_frame_related_insn;
struct m32c_pv_state st;
@@ -1864,7 +1884,8 @@ m32c_frame_base (struct frame_info *this_frame,
{
struct m32c_prologue *p
= m32c_analyze_frame_prologue (this_frame, this_prologue_cache);
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+ gdbarch *arch = get_frame_arch (this_frame);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
/* In functions that use alloca, the distance between the stack
pointer and the frame base varies dynamically, so we can't use
@@ -1914,7 +1935,8 @@ static struct value *
m32c_prev_register (struct frame_info *this_frame,
void **this_prologue_cache, int regnum)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+ gdbarch *arch = get_frame_arch (this_frame);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (arch);
struct m32c_prologue *p
= m32c_analyze_frame_prologue (this_frame, this_prologue_cache);
CORE_ADDR frame_base = m32c_frame_base (this_frame, this_prologue_cache);
@@ -1997,7 +2019,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
function_call_return_method return_method,
CORE_ADDR struct_addr)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach;
CORE_ADDR cfa;
@@ -2160,7 +2182,7 @@ m32c_return_value (struct gdbarch *gdbarch,
gdb_byte *readbuf,
const gdb_byte *writebuf)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum return_value_convention conv;
ULONGEST valtype_len = TYPE_LENGTH (valtype);
@@ -2291,7 +2313,7 @@ static CORE_ADDR
m32c_skip_trampoline_code (struct frame_info *frame, CORE_ADDR stop_pc)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* It would be nicer to simply look up the addresses of known
@@ -2537,7 +2559,7 @@ m32c_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc,
struct m32c_prologue p;
struct regcache *regcache = get_current_regcache ();
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ m32c_gdbarch_tdep *tdep = (m32c_gdbarch_tdep *) gdbarch_tdep (gdbarch);
if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
internal_error (__FILE__, __LINE__,
@@ -2572,7 +2594,6 @@ static struct gdbarch *
m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch *gdbarch;
- struct gdbarch_tdep *tdep;
unsigned long mach = info.bfd_arch_info->mach;
/* Find a candidate among the list of architectures we've created
@@ -2582,7 +2603,7 @@ m32c_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
arches = gdbarch_list_lookup_by_info (arches->next, &info))
return arches->gdbarch;
- tdep = XCNEW (struct gdbarch_tdep);
+ m32c_gdbarch_tdep *tdep = new m32c_gdbarch_tdep;
gdbarch = gdbarch_alloc (&info, tdep);
/* Essential types. */