From 345bd07cce33565f1cd66acabdaf387ca3a7ccb3 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 15 Nov 2021 11:29:39 -0500 Subject: gdb: fix gdbarch_tdep ODR violation I would like to be able to use non-trivial types in gdbarch_tdep types. This is not possible at the moment (in theory), because of the one definition rule. To allow it, rename all gdbarch_tdep types to _gdbarch_tdep, and make them inherit from a gdbarch_tdep base class. The inheritance is necessary to be able to pass pointers to all these _gdbarch_tdep objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep. These objects are never deleted through a base class pointer, so I didn't include a virtual destructor. In the future, if gdbarch objects deletable, I could imagine that the gdbarch_tdep objects could become owned by the gdbarch objects, and then it would become useful to have a virtual destructor (so that the gdbarch object can delete the owned gdbarch_tdep object). But that's not necessary right now. It turns out that RISC-V already has a gdbarch_tdep that is non-default-constructible, so that provides a good motivation for this change. Most changes are fairly straightforward, mostly needing to add some casts all over the place. There is however the xtensa architecture, doing its own little weird thing to define its gdbarch_tdep. I did my best to adapt it, but I can't test those changes. Change-Id: Ic001903f91ddd106bd6ca09a79dabe8df2d69f3b --- gdb/aarch64-fbsd-tdep.c | 2 +- gdb/aarch64-linux-tdep.c | 11 +- gdb/aarch64-newlib-tdep.c | 2 +- gdb/aarch64-tdep.c | 60 ++++++----- gdb/aarch64-tdep.h | 32 +++--- gdb/alpha-linux-tdep.c | 4 +- gdb/alpha-netbsd-tdep.c | 2 +- gdb/alpha-obsd-tdep.c | 2 +- gdb/alpha-tdep.c | 26 ++--- gdb/alpha-tdep.h | 24 +++-- gdb/amd64-darwin-tdep.c | 2 +- gdb/amd64-fbsd-tdep.c | 4 +- gdb/amd64-linux-tdep.c | 8 +- gdb/amd64-netbsd-tdep.c | 2 +- gdb/amd64-obsd-tdep.c | 2 +- gdb/amd64-sol2-tdep.c | 2 +- gdb/amd64-tdep.c | 36 +++---- gdb/amd64-windows-tdep.c | 2 +- gdb/arc-linux-tdep.c | 4 +- gdb/arc-tdep.c | 20 ++-- gdb/arc-tdep.h | 14 +-- gdb/arm-fbsd-tdep.c | 4 +- gdb/arm-linux-tdep.c | 4 +- gdb/arm-netbsd-tdep.c | 4 +- gdb/arm-none-tdep.c | 2 +- gdb/arm-obsd-tdep.c | 2 +- gdb/arm-tdep.c | 123 ++++++++++++---------- gdb/arm-tdep.h | 65 ++++++------ gdb/arm-wince-tdep.c | 2 +- gdb/avr-tdep.c | 36 ++++--- gdb/bfin-tdep.c | 12 ++- gdb/bfin-tdep.h | 4 +- gdb/bpf-tdep.c | 4 +- gdb/cris-linux-tdep.c | 2 +- gdb/cris-tdep.c | 31 +++--- gdb/cris-tdep.h | 8 +- gdb/csky-tdep.c | 3 +- gdb/csky-tdep.h | 2 +- gdb/frv-tdep.c | 37 +++---- gdb/ft32-tdep.c | 8 +- gdb/ft32-tdep.h | 4 +- gdb/gdbarch.h | 2 + gdb/gdbarch.sh | 2 + gdb/hppa-bsd-tdep.c | 2 +- gdb/hppa-linux-tdep.c | 4 +- gdb/hppa-tdep.c | 22 ++-- gdb/hppa-tdep.h | 23 +++-- gdb/i386-bsd-tdep.c | 2 +- gdb/i386-darwin-tdep.c | 4 +- gdb/i386-fbsd-tdep.c | 8 +- gdb/i386-gnu-tdep.c | 2 +- gdb/i386-go32-tdep.c | 2 +- gdb/i386-linux-tdep.c | 4 +- gdb/i386-netbsd-tdep.c | 4 +- gdb/i386-nto-tdep.c | 6 +- gdb/i386-obsd-tdep.c | 2 +- gdb/i386-sol2-tdep.c | 2 +- gdb/i386-tdep.c | 111 ++++++++++---------- gdb/i386-tdep.h | 136 ++++++++++++------------- gdb/i386-windows-tdep.c | 2 +- gdb/i387-tdep.c | 23 +++-- gdb/ia64-linux-tdep.c | 2 +- gdb/ia64-tdep.c | 14 +-- gdb/ia64-tdep.h | 23 +++-- gdb/lm32-tdep.c | 5 +- gdb/m32c-tdep.c | 113 ++++++++++++--------- gdb/m32r-tdep.c | 3 +- gdb/m32r-tdep.h | 4 +- gdb/m68hc11-tdep.c | 60 +++++++---- gdb/m68k-bsd-tdep.c | 2 +- gdb/m68k-linux-tdep.c | 2 +- gdb/m68k-tdep.c | 57 ++++++----- gdb/m68k-tdep.h | 22 ++-- gdb/mep-tdep.c | 28 +++-- gdb/microblaze-tdep.c | 3 +- gdb/microblaze-tdep.h | 2 +- gdb/mips-linux-tdep.c | 4 +- gdb/mips-tdep.c | 164 +++++++++++++++++++----------- gdb/mips-tdep.h | 30 +++--- gdb/mn10300-tdep.c | 7 +- gdb/mn10300-tdep.h | 11 +- gdb/moxie-tdep.c | 3 +- gdb/moxie-tdep.h | 2 +- gdb/msp430-tdep.c | 32 +++--- gdb/nds32-tdep.c | 24 ++--- gdb/nds32-tdep.h | 10 +- gdb/nios2-linux-tdep.c | 2 +- gdb/nios2-tdep.c | 7 +- gdb/nios2-tdep.h | 10 +- gdb/or1k-tdep.c | 23 +++-- gdb/ppc-fbsd-tdep.c | 8 +- gdb/ppc-linux-tdep.c | 18 ++-- gdb/ppc-netbsd-tdep.c | 2 +- gdb/ppc-obsd-tdep.c | 2 +- gdb/ppc-sysv-tdep.c | 22 ++-- gdb/ppc-tdep.h | 104 +++++++++---------- gdb/ppc64-tdep.c | 2 +- gdb/riscv-linux-tdep.c | 2 +- gdb/riscv-tdep.c | 37 ++++--- gdb/riscv-tdep.h | 5 +- gdb/rl78-tdep.c | 41 ++++---- gdb/rs6000-aix-tdep.c | 19 ++-- gdb/rs6000-lynx178-tdep.c | 6 +- gdb/rs6000-tdep.c | 121 +++++++++++----------- gdb/rx-tdep.c | 16 +-- gdb/s12z-tdep.c | 4 +- gdb/s390-linux-tdep.c | 20 ++-- gdb/s390-tdep.c | 74 +++++++------- gdb/s390-tdep.h | 33 +++--- gdb/sh-linux-tdep.c | 2 +- gdb/sh-netbsd-tdep.c | 2 +- gdb/sh-tdep.c | 11 +- gdb/sh-tdep.h | 14 +-- gdb/sparc-linux-tdep.c | 5 +- gdb/sparc-netbsd-tdep.c | 2 +- gdb/sparc-sol2-tdep.c | 2 +- gdb/sparc-tdep.c | 21 ++-- gdb/sparc-tdep.h | 43 ++++---- gdb/sparc64-fbsd-tdep.c | 2 +- gdb/sparc64-linux-tdep.c | 5 +- gdb/sparc64-netbsd-tdep.c | 2 +- gdb/sparc64-obsd-tdep.c | 2 +- gdb/sparc64-sol2-tdep.c | 2 +- gdb/sparc64-tdep.c | 10 +- gdb/tic6x-linux-tdep.c | 6 +- gdb/tic6x-tdep.c | 11 +- gdb/tic6x-tdep.h | 10 +- gdb/v850-tdep.c | 30 +++--- gdb/xtensa-config.c | 9 +- gdb/xtensa-linux-tdep.c | 2 +- gdb/xtensa-tdep.c | 254 +++++++++++++++++++++++++--------------------- gdb/xtensa-tdep.h | 180 +++++++++++++------------------- gdb/z80-tdep.c | 26 +++-- 133 files changed, 1514 insertions(+), 1325 deletions(-) (limited to 'gdb') diff --git a/gdb/aarch64-fbsd-tdep.c b/gdb/aarch64-fbsd-tdep.c index 3f22d41..7342e7b 100644 --- a/gdb/aarch64-fbsd-tdep.c +++ b/gdb/aarch64-fbsd-tdep.c @@ -153,7 +153,7 @@ aarch64_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, static void aarch64_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index abb8be3..7a9cf0c 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -286,7 +286,7 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self, { struct gdbarch *gdbarch = get_frame_arch (this_frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR sp = get_frame_register_unsigned (this_frame, AARCH64_SP_REGNUM); CORE_ADDR sigcontext_addr = (sp + AARCH64_RT_SIGFRAME_UCONTEXT_OFFSET + AARCH64_UCONTEXT_SIGCONTEXT_OFFSET ); @@ -640,7 +640,8 @@ aarch64_linux_collect_sve_regset (const struct regset *regset, gdb_byte *header = (gdb_byte *) buf; struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - uint64_t vq = gdbarch_tdep (gdbarch)->vq; + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); + uint64_t vq = tdep->vq; gdb_assert (buf != NULL); gdb_assert (size > SVE_HEADER_SIZE); @@ -675,7 +676,7 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", AARCH64_LINUX_SIZEOF_GREGSET, AARCH64_LINUX_SIZEOF_GREGSET, &aarch64_linux_gregset, NULL, cb_data); @@ -1719,7 +1720,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, enum gdb_signal siggnal) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->has_mte () || siggnal != GDB_SIGNAL_SEGV) return; @@ -1788,7 +1789,7 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) NULL }; static const char *const stap_register_indirection_suffixes[] = { "]", NULL }; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->lowest_pc = 0x8000; diff --git a/gdb/aarch64-newlib-tdep.c b/gdb/aarch64-newlib-tdep.c index b5e57bc..9805967 100644 --- a/gdb/aarch64-newlib-tdep.c +++ b/gdb/aarch64-newlib-tdep.c @@ -29,7 +29,7 @@ static void aarch64_newlib_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Jump buffer - support for longjmp. Offset of original PC in jump buffer (in registers). */ diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 42b8494..392110a 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -248,7 +248,7 @@ class instruction_reader : public abstract_instruction_reader THIS_FRAME. */ static CORE_ADDR -aarch64_frame_unmask_lr (struct gdbarch_tdep *tdep, +aarch64_frame_unmask_lr (aarch64_gdbarch_tdep *tdep, struct frame_info *this_frame, CORE_ADDR addr) { if (tdep->has_pauth () @@ -500,7 +500,8 @@ aarch64_analyze_prologue (struct gdbarch *gdbarch, } else if (inst.opcode->iclass == ic_system) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep + = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ra_state_val = 0; if (insn == 0xd503233f /* paciasp. */ @@ -635,7 +636,7 @@ aarch64_analyze_prologue_test (void) struct aarch64_prologue_cache cache; cache.saved_regs = trad_frame_alloc_saved_regs (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Test the simple prologue in which frame pointer is used. */ { @@ -1037,7 +1038,9 @@ aarch64_prologue_frame_unwind_stop_reason (struct frame_info *this_frame, return UNWIND_UNAVAILABLE; /* Halt the backtrace at "_start". */ - if (cache->prev_pc <= gdbarch_tdep (get_frame_arch (this_frame))->lowest_pc) + gdbarch *arch = get_frame_arch (this_frame); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (arch); + if (cache->prev_pc <= tdep->lowest_pc) return UNWIND_OUTERMOST; /* We've hit a wall, stop. */ @@ -1079,7 +1082,8 @@ aarch64_prologue_prev_register (struct frame_info *this_frame, { CORE_ADDR lr; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep + = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); lr = frame_unwind_register_unsigned (this_frame, AARCH64_LR_REGNUM); @@ -1247,7 +1251,8 @@ static struct value * aarch64_dwarf2_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (arch); CORE_ADDR lr; switch (regnum) @@ -1273,7 +1278,7 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); switch (regnum) { @@ -1313,7 +1318,7 @@ static bool aarch64_execute_dwarf_cfa_vendor_op (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct dwarf2_frame_state_reg *ra_state; if (op == DW_CFA_AARCH64_negate_ra_state) @@ -1952,7 +1957,7 @@ aarch64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp) static struct type * aarch64_vnq_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vnq_type == NULL) { @@ -1979,7 +1984,7 @@ aarch64_vnq_type (struct gdbarch *gdbarch) static struct type * aarch64_vnd_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vnd_type == NULL) { @@ -2009,7 +2014,7 @@ aarch64_vnd_type (struct gdbarch *gdbarch) static struct type * aarch64_vns_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vns_type == NULL) { @@ -2039,7 +2044,7 @@ aarch64_vns_type (struct gdbarch *gdbarch) static struct type * aarch64_vnh_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vnh_type == NULL) { @@ -2072,7 +2077,7 @@ aarch64_vnh_type (struct gdbarch *gdbarch) static struct type * aarch64_vnb_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vnb_type == NULL) { @@ -2099,7 +2104,7 @@ aarch64_vnb_type (struct gdbarch *gdbarch) static struct type * aarch64_vnv_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->vnv_type == NULL) { @@ -2170,7 +2175,7 @@ aarch64_vnv_type (struct gdbarch *gdbarch) static int aarch64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (reg >= AARCH64_DWARF_X0 && reg <= AARCH64_DWARF_X0 + 30) return AARCH64_X0_REGNUM + reg - AARCH64_DWARF_X0; @@ -2457,7 +2462,7 @@ aarch64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) CORE_ADDR jb_addr; gdb_byte buf[X_REGISTER_SIZE]; struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); jb_addr = get_frame_register_unsigned (frame, AARCH64_X0_REGNUM); @@ -2488,7 +2493,7 @@ aarch64_gen_return_address (struct gdbarch *gdbarch, static const char * aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); static const char *const q_name[] = { @@ -2602,7 +2607,7 @@ aarch64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) static struct type * aarch64_pseudo_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); int p_regnum = regnum - gdbarch_num_regs (gdbarch); @@ -2639,7 +2644,7 @@ static int aarch64_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *group) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); int p_regnum = regnum - gdbarch_num_regs (gdbarch); @@ -2693,7 +2698,7 @@ static struct value * aarch64_pseudo_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct value *result_value = allocate_value (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; @@ -2763,7 +2768,7 @@ static void aarch64_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); regnum -= gdbarch_num_regs (gdbarch); if (regnum >= AARCH64_Q0_REGNUM && regnum < AARCH64_Q0_REGNUM + 32) @@ -3328,7 +3333,7 @@ aarch64_add_reggroups (struct gdbarch *gdbarch) static int aarch64_cannot_store_register (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->has_pauth ()) return 0; @@ -3375,7 +3380,8 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) best_arch != nullptr; best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) { - struct gdbarch_tdep *tdep = gdbarch_tdep (best_arch->gdbarch); + aarch64_gdbarch_tdep *tdep + = (aarch64_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch); if (tdep && tdep->vq == vq) return best_arch->gdbarch; } @@ -3483,7 +3489,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* AArch64 code is always little-endian. */ info.byte_order_for_code = BFD_ENDIAN_LITTLE; - struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep); + aarch64_gdbarch_tdep *tdep = new aarch64_gdbarch_tdep; struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); /* This should be low enough for everything. */ @@ -3605,7 +3611,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void aarch64_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + aarch64_gdbarch_tdep *tdep = (aarch64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep == NULL) return; @@ -3825,7 +3831,9 @@ aarch64_record_data_proc_imm (insn_decode_record *aarch64_insn_r) static unsigned int aarch64_record_branch_except_sys (insn_decode_record *aarch64_insn_r) { - struct gdbarch_tdep *tdep = gdbarch_tdep (aarch64_insn_r->gdbarch); + + aarch64_gdbarch_tdep *tdep + = (aarch64_gdbarch_tdep *) gdbarch_tdep (aarch64_insn_r->gdbarch); uint8_t insn_bits24_27, insn_bits28_31, insn_bits22_23; uint32_t record_buf[4]; diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 7bf612b..efb0fa2 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -25,6 +25,7 @@ #include "arch/aarch64.h" #include "displaced-stepping.h" #include "infrun.h" +#include "gdbarch.h" /* Forward declarations. */ struct gdbarch; @@ -60,31 +61,32 @@ struct regset; #define AARCH64_DISPLACED_MODIFIED_INSNS 1 /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct aarch64_gdbarch_tdep : gdbarch_tdep { /* Lowest address at which instructions will appear. */ - CORE_ADDR lowest_pc; + CORE_ADDR lowest_pc = 0; /* Offset to PC value in jump buffer. If this is negative, longjmp support will be disabled. */ - int jb_pc; + int jb_pc = 0; /* And the size of each entry in the buf. */ - size_t jb_elt_size; + size_t jb_elt_size = 0; /* Types for AdvSISD registers. */ - struct type *vnq_type; - struct type *vnd_type; - struct type *vns_type; - struct type *vnh_type; - struct type *vnb_type; - struct type *vnv_type; + struct type *vnq_type = nullptr; + struct type *vnd_type = nullptr; + struct type *vns_type = nullptr; + struct type *vnh_type = nullptr; + struct type *vnb_type = nullptr; + struct type *vnv_type = nullptr; /* syscall record. */ - int (*aarch64_syscall_record) (struct regcache *regcache, unsigned long svc_number); + int (*aarch64_syscall_record) (struct regcache *regcache, + unsigned long svc_number) = nullptr; /* The VQ value for SVE targets, or zero if SVE is not supported. */ - uint64_t vq; + uint64_t vq = 0; /* Returns true if the target supports SVE. */ bool has_sve () const @@ -92,8 +94,8 @@ struct gdbarch_tdep return vq != 0; } - int pauth_reg_base; - int pauth_ra_state_regnum; + int pauth_reg_base = 0; + int pauth_ra_state_regnum = 0; /* Returns true if the target supports pauth. */ bool has_pauth () const @@ -102,7 +104,7 @@ struct gdbarch_tdep } /* First MTE register. This is -1 if no MTE registers are available. */ - int mte_reg_base; + int mte_reg_base = 0; /* Returns true if the target supports MTE. */ bool has_mte () const diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c index 0a00fc1..b821a6b 100644 --- a/gdb/alpha-linux-tdep.c +++ b/gdb/alpha-linux-tdep.c @@ -354,8 +354,6 @@ alpha_linux_gdb_signal_to_target (struct gdbarch *gdbarch, static void alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep; - linux_init_abi (info, gdbarch, 0); /* Hook into the DWARF CFI frame unwinder. */ @@ -364,7 +362,7 @@ alpha_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Hook into the MDEBUG frame unwinder. */ alpha_mdebug_init_abi (info, gdbarch); - tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset; tdep->sigcontext_addr = alpha_linux_sigcontext_addr; tdep->pc_in_sigtramp = alpha_linux_pc_in_sigtramp; diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c index 0b03aa1..b19f76b 100644 --- a/gdb/alpha-netbsd-tdep.c +++ b/gdb/alpha-netbsd-tdep.c @@ -250,7 +250,7 @@ static void alphanbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Hook into the DWARF CFI frame unwinder. */ alpha_dwarf2_init_abi (info, gdbarch); diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c index 0afd4dc..7ca5ca1 100644 --- a/gdb/alpha-obsd-tdep.c +++ b/gdb/alpha-obsd-tdep.c @@ -97,7 +97,7 @@ alphaobsd_sigcontext_addr (struct frame_info *this_frame) static void alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Hook into the DWARF CFI frame unwinder. */ alpha_dwarf2_init_abi (info, gdbarch); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 03935d1..760a18a 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -615,11 +615,12 @@ alpha_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { enum type_code code = type->code (); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION || code == TYPE_CODE_ARRAY) - && gdbarch_tdep (gdbarch)->return_in_memory (type)) + && tdep->return_in_memory (type)) { if (readbuf) { @@ -850,7 +851,7 @@ static int alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR jb_addr; gdb_byte raw_buffer[ALPHA_REGISTER_SIZE]; @@ -882,7 +883,6 @@ alpha_sigtramp_frame_unwind_cache (struct frame_info *this_frame, void **this_prologue_cache) { struct alpha_sigtramp_unwind_cache *info; - struct gdbarch_tdep *tdep; if (*this_prologue_cache) return (struct alpha_sigtramp_unwind_cache *) *this_prologue_cache; @@ -890,7 +890,8 @@ alpha_sigtramp_frame_unwind_cache (struct frame_info *this_frame, info = FRAME_OBSTACK_ZALLOC (struct alpha_sigtramp_unwind_cache); *this_prologue_cache = info; - tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (arch); info->sigcontext_addr = tdep->sigcontext_addr (this_frame); return info; @@ -903,7 +904,7 @@ static CORE_ADDR alpha_sigtramp_register_address (struct gdbarch *gdbarch, CORE_ADDR sigcontext_addr, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum >= 0 && regnum < 32) return sigcontext_addr + tdep->sc_regs_offset + regnum * 8; @@ -924,7 +925,7 @@ alpha_sigtramp_frame_this_id (struct frame_info *this_frame, struct frame_id *this_id) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct alpha_sigtramp_unwind_cache *info = alpha_sigtramp_frame_unwind_cache (this_frame, this_prologue_cache); CORE_ADDR stack_addr, code_addr; @@ -999,14 +1000,16 @@ alpha_sigtramp_frame_sniffer (const struct frame_unwind *self, /* We shouldn't even bother to try if the OSABI didn't register a sigcontext_addr handler or pc_in_sigtramp handler. */ - if (gdbarch_tdep (gdbarch)->sigcontext_addr == NULL) + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->sigcontext_addr == NULL) return 0; - if (gdbarch_tdep (gdbarch)->pc_in_sigtramp == NULL) + + if (tdep->pc_in_sigtramp == NULL) return 0; /* Otherwise we should be in a signal frame. */ find_pc_partial_function (pc, &name, NULL, NULL); - if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (gdbarch, pc, name)) + if (tdep->pc_in_sigtramp (gdbarch, pc, name)) return 1; return 0; @@ -1038,7 +1041,7 @@ static int heuristic_fence_post = 0; static CORE_ADDR alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + alpha_gdbarch_tdep *tdep = (alpha_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR last_non_nop = pc; CORE_ADDR fence = pc - heuristic_fence_post; CORE_ADDR orig_pc = pc; @@ -1724,7 +1727,6 @@ alpha_software_single_step (struct regcache *regcache) static struct gdbarch * alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; /* Find a candidate among extant architectures. */ @@ -1732,7 +1734,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (arches != NULL) return arches->gdbarch; - tdep = XCNEW (struct gdbarch_tdep); + alpha_gdbarch_tdep *tdep = new alpha_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Lowest text address. This is used by heuristic_proc_start() diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h index c1fd694..c1674fe 100644 --- a/gdb/alpha-tdep.h +++ b/gdb/alpha-tdep.h @@ -19,6 +19,8 @@ #ifndef ALPHA_TDEP_H #define ALPHA_TDEP_H +#include "gdbarch.h" + struct regcache; /* Say how long (ordinary) registers are. This is a piece of bogosity @@ -68,38 +70,38 @@ struct regcache; #define ALPHA_NUM_ARG_REGS 6 /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct alpha_gdbarch_tdep : gdbarch_tdep { - CORE_ADDR vm_min_address; /* Used by alpha_heuristic_proc_start. */ + CORE_ADDR vm_min_address = 0; /* Used by alpha_heuristic_proc_start. */ /* If PC is inside a dynamically-generated signal trampoline function (i.e. one copied onto the user stack at run-time), return how many bytes PC is beyond the start of that function. Otherwise, return -1. */ - LONGEST (*dynamic_sigtramp_offset) (struct gdbarch *, CORE_ADDR); + LONGEST (*dynamic_sigtramp_offset) (struct gdbarch *, CORE_ADDR) = nullptr; /* Translate a signal handler stack base address into the address of the sigcontext structure for that signal handler. */ - CORE_ADDR (*sigcontext_addr) (struct frame_info *); + CORE_ADDR (*sigcontext_addr) (struct frame_info *) = nullptr; /* Does the PC fall in a signal trampoline. */ /* NOTE: cagney/2004-04-30: Do not copy/clone this code. Instead look at tramp-frame.h and other simpler per-architecture sigtramp unwinders. */ int (*pc_in_sigtramp) (struct gdbarch *gdbarch, CORE_ADDR pc, - const char *name); + const char *name) = nullptr; /* If TYPE will be returned in memory, return true. */ - int (*return_in_memory) (struct type *type); + int (*return_in_memory) (struct type *type) = nullptr; /* Offset of registers in `struct sigcontext'. */ - int sc_pc_offset; - int sc_regs_offset; - int sc_fpregs_offset; + int sc_pc_offset = 0; + int sc_regs_offset = 0; + int sc_fpregs_offset = 0; - int jb_pc; /* Offset to PC value in jump buffer. + int jb_pc = 0; /* Offset to PC value in jump buffer. If htis is negative, longjmp support will be disabled. */ - size_t jb_elt_size; /* And the size of each entry in the buf. */ + size_t jb_elt_size = 0; /* And the size of each entry in the buf. */ }; extern unsigned int alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc); diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c index 3bd6296..5cf3ff2 100644 --- a/gdb/amd64-darwin-tdep.c +++ b/gdb/amd64-darwin-tdep.c @@ -97,7 +97,7 @@ amd64_darwin_sigcontext_addr (struct frame_info *this_frame) static void x86_darwin_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); amd64_init_abi (info, gdbarch, amd64_target_description (X86_XSTATE_SSE_MASK, true)); diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c index 2894313..5069342 100644 --- a/gdb/amd64-fbsd-tdep.c +++ b/gdb/amd64-fbsd-tdep.c @@ -195,7 +195,7 @@ amd64fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL, cb_data); @@ -229,7 +229,7 @@ amd64fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, static void amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 715add8..817a197 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1650,7 +1650,7 @@ amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", 27 * 8, 27 * 8, &i386_gregset, NULL, cb_data); cb (".reg2", 512, 512, &amd64_fpregset, NULL, cb_data); @@ -1787,7 +1787,7 @@ static void amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch, int num_disp_step_buffers) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, num_disp_step_buffers); @@ -1840,7 +1840,7 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch, static void amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct tdesc_arch_data *tdesc_data = info.tdesc_data; const struct tdesc_feature *feature; int valid_p; @@ -2054,7 +2054,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) static void amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct tdesc_arch_data *tdesc_data = info.tdesc_data; const struct tdesc_feature *feature; int valid_p; diff --git a/gdb/amd64-netbsd-tdep.c b/gdb/amd64-netbsd-tdep.c index 439dd91..be8ee37 100644 --- a/gdb/amd64-netbsd-tdep.c +++ b/gdb/amd64-netbsd-tdep.c @@ -97,7 +97,7 @@ int amd64nbsd_r_reg_offset[] = static void amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Initialize general-purpose register set details first. */ tdep->gregset_reg_offset = amd64nbsd_r_reg_offset; diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c index 070f196..0da1dbf 100644 --- a/gdb/amd64-obsd-tdep.c +++ b/gdb/amd64-obsd-tdep.c @@ -420,7 +420,7 @@ static const struct frame_unwind amd64obsd_trapframe_unwind = static void amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); amd64_init_abi (info, gdbarch, amd64_target_description (X86_XSTATE_SSE_MASK, true)); diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c index e561c0d..4cb243b 100644 --- a/gdb/amd64-sol2-tdep.c +++ b/gdb/amd64-sol2-tdep.c @@ -80,7 +80,7 @@ amd64_sol2_mcontext_addr (struct frame_info *this_frame) static void amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->gregset_reg_offset = amd64_sol2_gregset_reg_offset; tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset); diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index de04bbd..7c67359 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -247,7 +247,7 @@ static const int amd64_dwarf_regmap_len = static int amd64_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ymm0_regnum = tdep->ymm0_regnum; int regnum = -1; @@ -331,7 +331,7 @@ static const char * const amd64_dword_names[] = static const char * amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_byte_regnum_p (gdbarch, regnum)) return amd64_byte_names[regnum - tdep->al_regnum]; else if (i386_zmm_regnum_p (gdbarch, regnum)) @@ -353,7 +353,7 @@ amd64_pseudo_register_read_value (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); value *result_value = allocate_value (register_type (gdbarch, regnum)); VALUE_LVAL (result_value) = lval_register; @@ -413,7 +413,7 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_byte_regnum_p (gdbarch, regnum)) { @@ -465,7 +465,7 @@ static int amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_byte_regnum_p (gdbarch, regnum)) { @@ -2739,7 +2739,7 @@ static struct amd64_frame_cache * amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct amd64_frame_cache *cache; CORE_ADDR addr; @@ -2821,7 +2821,8 @@ amd64_sigtramp_frame_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); /* We shouldn't even bother if we don't have a sigcontext_addr handler. */ @@ -3021,7 +3022,7 @@ amd64_supply_fpregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (len >= tdep->sizeof_fpregset); amd64_supply_fxsave (regcache, regnum, fpregs); @@ -3038,7 +3039,7 @@ amd64_collect_fpregset (const struct regset *regset, int regnum, void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (len >= tdep->sizeof_fpregset); amd64_collect_fxsave (regcache, regnum, fpregs); @@ -3062,7 +3063,8 @@ amd64_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) gdb_byte buf[8]; CORE_ADDR jb_addr; struct gdbarch *gdbarch = get_frame_arch (frame); - int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset; + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int jb_pc_offset = tdep->jb_pc_offset; int len = TYPE_LENGTH (builtin_type (gdbarch)->builtin_func_ptr); /* If JB_PC_OFFSET is -1, we have no way to find out where the @@ -3105,7 +3107,7 @@ void amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, const target_desc *default_tdesc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct target_desc *tdesc = info.target_desc; static const char *const stap_integer_prefixes[] = { "$", NULL }; static const char *const stap_register_prefixes[] = { "%", NULL }; @@ -3284,7 +3286,7 @@ amd64_none_init_abi (gdbarch_info info, gdbarch *arch) static struct type * amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); switch (regnum - tdep->eax_regnum) { @@ -3302,7 +3304,7 @@ void amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, const target_desc *default_tdesc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); amd64_init_abi (info, gdbarch, default_tdesc); @@ -3372,7 +3374,7 @@ amd64_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); i387_supply_fxsave (regcache, regnum, fxsave); @@ -3395,7 +3397,7 @@ amd64_supply_xsave (struct regcache *regcache, int regnum, const void *xsave) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); i387_supply_xsave (regcache, regnum, xsave); @@ -3430,7 +3432,7 @@ amd64_collect_fxsave (const struct regcache *regcache, int regnum, void *fxsave) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte *regs = (gdb_byte *) fxsave; i387_collect_fxsave (regcache, regnum, fxsave); @@ -3451,7 +3453,7 @@ amd64_collect_xsave (const struct regcache *regcache, int regnum, void *xsave, int gcore) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte *regs = (gdb_byte *) xsave; i387_collect_xsave (regcache, regnum, xsave, gcore); diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index ed783f6..fb3fe48 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -1277,7 +1277,7 @@ amd64_windows_auto_wide_charset (void) static void amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* The dwarf2 unwinder (appended very early by i386_gdbarch_init) is preferred over the SEH one. The reasons are: diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index 448fa37..de95d5a 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -410,7 +410,7 @@ static std::vector arc_linux_software_single_step (struct regcache *regcache) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct disassemble_info di = arc_disassemble_info (gdbarch); /* Read current instruction. */ @@ -692,7 +692,7 @@ arc_linux_core_read_description (struct gdbarch *gdbarch, static void arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (gdbarch); arc_linux_debug_printf ("GNU/Linux OS/ABI initialization."); diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 35874eb..475ba2a 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -1002,7 +1002,7 @@ arc_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) arc_debug_printf ("called"); struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int pc_offset = tdep->jb_pc * ARC_REGISTER_SIZE; gdb_byte buf[ARC_REGISTER_SIZE]; CORE_ADDR jb_addr = get_frame_register_unsigned (frame, ARC_FIRST_ARG_REGNUM); @@ -1832,7 +1832,8 @@ arc_make_sigtramp_frame_cache (struct frame_info *this_frame) { arc_debug_printf ("called"); - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (arch); /* Allocate new frame cache instance and space for saved register info. */ struct arc_frame_cache *cache = FRAME_OBSTACK_ZALLOC (struct arc_frame_cache); @@ -1906,11 +1907,10 @@ arc_sigtramp_frame_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache) { - struct gdbarch_tdep *tdep; - arc_debug_printf ("called"); - tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (arch); /* If we have a sigcontext_addr handler, then just return 1 (same as the "default_frame_sniffer ()"). */ @@ -2295,11 +2295,11 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Allocate the ARC-private target-dependent information structure, and the GDB target-independent information structure. */ - gdb::unique_xmalloc_ptr tdep - (XCNEW (struct gdbarch_tdep)); + std::unique_ptr tdep_holder (new arc_gdbarch_tdep); + arc_gdbarch_tdep *tdep = tdep_holder.get (); tdep->jb_pc = -1; /* No longjmp support by default. */ tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data.get ()); - struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep.release ()); + struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep_holder.release ()); /* Data types. */ set_gdbarch_short_bit (gdbarch, 16); @@ -2384,7 +2384,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) It can override functions set earlier. */ gdbarch_init_osabi (info, gdbarch); - if (gdbarch_tdep (gdbarch)->jb_pc >= 0) + if (tdep->jb_pc >= 0) set_gdbarch_get_longjmp_target (gdbarch, arc_get_longjmp_target); /* Disassembler options. Enforce CPU if it was specified in XML target @@ -2454,7 +2454,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void arc_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arc_gdbarch_tdep *tdep = (arc_gdbarch_tdep *) gdbarch_tdep (gdbarch); fprintf_unfiltered (file, "arc_dump_tdep: jb_pc = %i\n", tdep->jb_pc); diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h index 8bb005c..d8495ed 100644 --- a/gdb/arc-tdep.h +++ b/gdb/arc-tdep.h @@ -121,27 +121,27 @@ extern bool arc_debug; /* Target-dependent information. */ -struct gdbarch_tdep +struct arc_gdbarch_tdep : gdbarch_tdep { /* Offset to PC value in jump buffer. If this is negative, longjmp support will be disabled. */ - int jb_pc; + int jb_pc = 0; /* Whether target has hardware (aka zero-delay) loops. */ - bool has_hw_loops; + bool has_hw_loops = false; /* Detect sigtramp. */ - bool (*is_sigtramp) (struct frame_info *); + bool (*is_sigtramp) (struct frame_info *) = nullptr; /* Get address of sigcontext for sigtramp. */ - CORE_ADDR (*sigcontext_addr) (struct frame_info *); + CORE_ADDR (*sigcontext_addr) (struct frame_info *) = nullptr; /* Offset of registers in `struct sigcontext'. */ - const int *sc_reg_offset; + const int *sc_reg_offset = nullptr; /* Number of registers in sc_reg_offsets. Most likely a ARC_LAST_REGNUM, but in theory it could be less, so it is kept separate. */ - int sc_num_regs; + int sc_num_regs = 0; }; /* Utility functions used by other ARC-specific modules. */ diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c index 3a17918..a1482c4 100644 --- a/gdb/arm-fbsd-tdep.c +++ b/gdb/arm-fbsd-tdep.c @@ -158,7 +158,7 @@ arm_fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", ARM_FBSD_SIZEOF_GREGSET, ARM_FBSD_SIZEOF_GREGSET, &arm_fbsd_gregset, NULL, cb_data); @@ -211,7 +211,7 @@ arm_fbsd_core_read_description (struct gdbarch *gdbarch, static void arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index c0dfc5f..025ecf0 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -712,7 +712,7 @@ arm_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", ARM_LINUX_SIZEOF_GREGSET, ARM_LINUX_SIZEOF_GREGSET, &arm_linux_gregset, NULL, cb_data); @@ -1714,7 +1714,7 @@ arm_linux_init_abi (struct gdbarch_info info, NULL }; static const char *const stap_register_indirection_suffixes[] = { "]", NULL }; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 1); diff --git a/gdb/arm-netbsd-tdep.c b/gdb/arm-netbsd-tdep.c index 38c2e81..bf4e46f 100644 --- a/gdb/arm-netbsd-tdep.c +++ b/gdb/arm-netbsd-tdep.c @@ -111,7 +111,7 @@ static void arm_netbsd_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->lowest_pc = 0x8000; switch (info.byte_order) @@ -148,7 +148,7 @@ static void arm_netbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); arm_netbsd_init_abi_common (info, gdbarch); diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c index 2816c59..a308c79 100644 --- a/gdb/arm-none-tdep.c +++ b/gdb/arm-none-tdep.c @@ -177,7 +177,7 @@ arm_none_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", ARM_NONE_SIZEOF_GREGSET, ARM_NONE_SIZEOF_GREGSET, &arm_none_gregset, nullptr, cb_data); diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c index ec7a748..4fa8853 100644 --- a/gdb/arm-obsd-tdep.c +++ b/gdb/arm-obsd-tdep.c @@ -76,7 +76,7 @@ static void armobsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->fp_model == ARM_FLOAT_AUTO) tdep->fp_model = ARM_FLOAT_SOFT_VFP; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 5b60831..7495434 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -332,7 +332,9 @@ bool arm_apcs_32 = true; int arm_psr_thumb_bit (struct gdbarch *gdbarch) { - if (gdbarch_tdep (gdbarch)->is_m) + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->is_m) return XPSR_T; else return CPSR_T; @@ -438,6 +440,7 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) struct bound_minimal_symbol sym; char type; arm_displaced_step_copy_insn_closure *dsc = nullptr; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (gdbarch_displaced_step_copy_insn_closure_by_addr_p (gdbarch)) dsc = ((arm_displaced_step_copy_insn_closure * ) @@ -465,7 +468,7 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) return 1; /* ARM v6-M and v7-M are always in Thumb mode. */ - if (gdbarch_tdep (gdbarch)->is_m) + if (tdep->is_m) return 1; /* If there are mapping symbols, consult them. */ @@ -568,10 +571,11 @@ arm_m_addr_is_magic (CORE_ADDR addr) static CORE_ADDR arm_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR val) { + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + /* On M-profile devices, do not strip the low bit from EXC_RETURN (the magic exception return address). */ - if (gdbarch_tdep (gdbarch)->is_m - && arm_m_addr_is_magic (val)) + if (tdep->is_m && arm_m_addr_is_magic (val)) return val; if (arm_apcs_32) @@ -1557,6 +1561,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR offset, current_pc; pv_t regs[ARM_FPS_REGNUM]; CORE_ADDR unrecognized_pc = 0; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Search the prologue looking for instructions that set up the frame pointer, adjust the stack pointer, and save registers. @@ -1661,7 +1666,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, } else if ((insn & 0xffff7fff) == 0xed6d0103 /* stfe f?, [sp, -#c]! */ - && gdbarch_tdep (gdbarch)->have_fpa_registers) + && tdep->have_fpa_registers) { if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; @@ -1672,7 +1677,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, } else if ((insn & 0xffbf0fff) == 0xec2d0200 /* sfmfd f0, 4, [sp!] */ - && gdbarch_tdep (gdbarch)->have_fpa_registers) + && tdep->have_fpa_registers) { int n_saved_fp_regs; unsigned int fp_start_reg, fp_bound_reg; @@ -1800,6 +1805,7 @@ arm_scan_prologue (struct frame_info *this_frame, CORE_ADDR prologue_start, prologue_end; CORE_ADDR prev_pc = get_frame_pc (this_frame); CORE_ADDR block_addr = get_frame_address_in_block (this_frame); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Assume there is no frame until proven otherwise. */ cache->framereg = ARM_SP_REGNUM; @@ -1865,7 +1871,7 @@ arm_scan_prologue (struct frame_info *this_frame, ULONGEST return_value; /* AAPCS does not use a frame register, so we can abort here. */ - if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS) + if (tdep->arm_abi == ARM_ABI_AAPCS) return; frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM); @@ -1930,7 +1936,9 @@ arm_prologue_unwind_stop_reason (struct frame_info *this_frame, /* This is meant to halt the backtrace at "_start". */ pc = get_frame_pc (this_frame); - if (pc <= gdbarch_tdep (get_frame_arch (this_frame))->lowest_pc) + gdbarch *arch = get_frame_arch (this_frame); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (arch); + if (pc <= tdep->lowest_pc) return UNWIND_OUTERMOST; /* If we've hit a wall, stop. */ @@ -3739,15 +3747,18 @@ arm_vfp_call_candidate (struct type *t, enum arm_vfp_cprc_base_type *base_type, static int arm_vfp_abi_for_function (struct gdbarch *gdbarch, struct type *func_type) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + /* Variadic functions always use the base ABI. Assume that functions without debug info are not variadic. */ if (func_type && check_typedef (func_type)->has_varargs ()) return 0; + /* The VFP ABI is only supported as a variant of AAPCS. */ if (tdep->arm_abi != ARM_ABI_AAPCS) return 0; - return gdbarch_tdep (gdbarch)->fp_model == ARM_FLOAT_VFP; + + return tdep->fp_model == ARM_FLOAT_VFP; } /* We currently only support passing parameters in integer registers, which @@ -3770,6 +3781,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int use_vfp_abi; struct type *ftype; unsigned vfp_regs_free = (1 << 16) - 1; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Determine the type of this function and whether the VFP ABI applies. */ @@ -3827,7 +3839,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, align = (align + ARM_INT_REGISTER_SIZE - 1) & ~(ARM_INT_REGISTER_SIZE - 1); /* Different ABIs have different maximum alignments. */ - if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_APCS) + if (tdep->arm_abi == ARM_ABI_APCS) { /* The APCS ABI only requires word alignment. */ align = ARM_INT_REGISTER_SIZE; @@ -4041,7 +4053,7 @@ arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, static struct type * arm_ext_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->arm_ext_type) tdep->arm_ext_type @@ -4054,7 +4066,7 @@ arm_ext_type (struct gdbarch *gdbarch) static struct type * arm_neon_double_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->neon_double_type == NULL) { @@ -4093,7 +4105,7 @@ arm_neon_double_type (struct gdbarch *gdbarch) static struct type * arm_neon_quad_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->neon_quad_type == NULL) { @@ -4131,7 +4143,7 @@ arm_neon_quad_type (struct gdbarch *gdbarch) static bool is_q_pseudo (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Q pseudo registers are available for both NEON (Q0~Q15) and MVE (Q0~Q7) features. */ @@ -4152,7 +4164,7 @@ is_q_pseudo (struct gdbarch *gdbarch, int regnum) static bool is_s_pseudo (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->have_s_pseudos && regnum >= tdep->s_pseudo_base @@ -4171,7 +4183,7 @@ is_s_pseudo (struct gdbarch *gdbarch, int regnum) static bool is_mve_pseudo (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->have_mve && regnum >= tdep->mve_pseudo_base @@ -4187,7 +4199,7 @@ is_mve_pseudo (struct gdbarch *gdbarch, int regnum) static struct type * arm_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (is_s_pseudo (gdbarch, regnum)) return builtin_type (gdbarch)->builtin_float; @@ -4369,9 +4381,10 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr) int buf_len; enum bfd_endian order = gdbarch_byte_order_for_code (gdbarch); int i, any, last_it, last_it_count; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* If we are using BKPT breakpoints, none of this is necessary. */ - if (gdbarch_tdep (gdbarch)->thumb2_breakpoint == NULL) + if (tdep->thumb2_breakpoint == NULL) return bpaddr; /* ARM mode does not have this problem. */ @@ -7676,7 +7689,7 @@ arm_displaced_init_closure (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, arm_displaced_step_copy_insn_closure *dsc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned int i, len, offset; enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); int size = dsc->is_thumb? 2 : 4; @@ -7839,7 +7852,7 @@ static const gdb_byte arm_default_thumb_be_breakpoint[] = THUMB_BE_BREAKPOINT; static int arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); if (arm_pc_is_thumb (gdbarch, *pcptr)) @@ -7874,7 +7887,7 @@ arm_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) static const gdb_byte * arm_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); switch (kind) { @@ -7946,10 +7959,11 @@ arm_extract_return_value (struct type *type, struct regcache *regs, { struct gdbarch *gdbarch = regs->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (TYPE_CODE_FLT == type->code ()) { - switch (gdbarch_tdep (gdbarch)->fp_model) + switch (tdep->fp_model) { case ARM_FLOAT_FPA: { @@ -8055,7 +8069,8 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type) return (TYPE_LENGTH (type) > 16); } - if (gdbarch_tdep (gdbarch)->arm_abi != ARM_ABI_APCS) + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->arm_abi != ARM_ABI_APCS) { /* The AAPCS says all aggregates not larger than a word are returned in a register. */ @@ -8158,8 +8173,9 @@ arm_store_return_value (struct type *type, struct regcache *regs, if (type->code () == TYPE_CODE_FLT) { gdb_byte buf[ARM_FP_REGISTER_SIZE]; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); - switch (gdbarch_tdep (gdbarch)->fp_model) + switch (tdep->fp_model) { case ARM_FLOAT_FPA: @@ -8246,7 +8262,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct type *func_type = function ? value_type (function) : NULL; enum arm_vfp_cprc_base_type vfp_base_type; int vfp_base_count; @@ -8314,7 +8330,7 @@ static int arm_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR jb_addr; gdb_byte buf[ARM_INT_REGISTER_SIZE]; @@ -8503,7 +8519,8 @@ static void show_fp_model (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch ()); + arm_gdbarch_tdep *tdep + = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); if (arm_fp_model == ARM_FLOAT_AUTO && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm) @@ -8540,7 +8557,8 @@ static void arm_show_abi (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch ()); + arm_gdbarch_tdep *tdep + = (arm_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); if (arm_abi_global == ARM_ABI_AUTO && gdbarch_bfd_arch_info (target_gdbarch ())->arch == bfd_arch_arm) @@ -8611,7 +8629,7 @@ show_disassembly_style_sfunc (struct ui_file *file, int from_tty, static const char * arm_register_name (struct gdbarch *gdbarch, int i) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (is_s_pseudo (gdbarch, i)) { @@ -8778,7 +8796,7 @@ static enum register_status arm_mve_pseudo_read (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* P0 is the first 16 bits of VPR. */ return regcache->raw_read_part (tdep->mve_vpr_regnum, 0, 2, buf); @@ -8792,11 +8810,10 @@ arm_pseudo_read (struct gdbarch *gdbarch, readable_regcache *regcache, char name_buf[4]; gdb_byte reg_buf[8]; int offset, double_regnum; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (regnum >= num_regs); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - if (is_q_pseudo (gdbarch, regnum)) { /* Quad-precision register. */ @@ -8865,7 +8882,7 @@ static void arm_mve_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* P0 is the first 16 bits of VPR. */ regcache->raw_write_part (tdep->mve_vpr_regnum, 0, 2, buf); @@ -8879,11 +8896,10 @@ arm_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache, char name_buf[4]; gdb_byte reg_buf[8]; int offset, double_regnum; + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (regnum >= num_regs); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - if (is_q_pseudo (gdbarch, regnum)) { /* Quad-precision register. */ @@ -8968,7 +8984,9 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum, static void arm_register_g_packet_guesses (struct gdbarch *gdbarch) { - if (gdbarch_tdep (gdbarch)->is_m) + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->is_m) { const target_desc *tdesc; @@ -9005,8 +9023,9 @@ arm_register_g_packet_guesses (struct gdbarch *gdbarch) static int arm_code_of_frame_writable (struct gdbarch *gdbarch, struct frame_info *frame) { - if (gdbarch_tdep (gdbarch)->is_m - && get_frame_type (frame) == SIGTRAMP_FRAME) + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->is_m && get_frame_type (frame) == SIGTRAMP_FRAME) { /* M-profile exception frames return to some magic PCs, where isn't writable at all. */ @@ -9037,7 +9056,6 @@ arm_gnu_triplet_regexp (struct gdbarch *gdbarch) static struct gdbarch * arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; struct gdbarch_list *best_arch; enum arm_abi_kind arm_abi = arm_abi_global; @@ -9406,12 +9424,13 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) best_arch != NULL; best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) { - if (arm_abi != ARM_ABI_AUTO - && arm_abi != gdbarch_tdep (best_arch->gdbarch)->arm_abi) + arm_gdbarch_tdep *tdep + = (arm_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch); + + if (arm_abi != ARM_ABI_AUTO && arm_abi != tdep->arm_abi) continue; - if (fp_model != ARM_FLOAT_AUTO - && fp_model != gdbarch_tdep (best_arch->gdbarch)->fp_model) + if (fp_model != ARM_FLOAT_AUTO && fp_model != tdep->fp_model) continue; /* There are various other properties in tdep that we do not @@ -9420,7 +9439,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) automatically disqualified. */ /* Do check is_m, though, since it might come from the binary. */ - if (is_m != gdbarch_tdep (best_arch->gdbarch)->is_m) + if (is_m != tdep->is_m) continue; /* Found a match. */ @@ -9430,7 +9449,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (best_arch != NULL) return best_arch->gdbarch; - tdep = XCNEW (struct gdbarch_tdep); + arm_gdbarch_tdep *tdep = new arm_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Record additional information about the architecture we are defining. @@ -9546,7 +9565,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* This "info float" is FPA-specific. Use the generic version if we do not have FPA. */ - if (gdbarch_tdep (gdbarch)->have_fpa_registers) + if (tdep->have_fpa_registers) set_gdbarch_print_float_info (gdbarch, arm_print_float_info); /* Internal <-> external register number maps. */ @@ -9692,7 +9711,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep == NULL) return; @@ -11868,7 +11887,8 @@ static int arm_record_coproc_data_proc (insn_decode_record *arm_insn_r) { uint32_t op, op1_ebit, coproc, bits_24_25; - struct gdbarch_tdep *tdep = gdbarch_tdep (arm_insn_r->gdbarch); + arm_gdbarch_tdep *tdep + = (arm_gdbarch_tdep *) gdbarch_tdep (arm_insn_r->gdbarch); struct regcache *reg_cache = arm_insn_r->regcache; arm_insn_r->opcode = bits (arm_insn_r->arm_insn, 24, 27); @@ -12352,9 +12372,10 @@ thumb_record_misc (insn_decode_record *thumb_insn_r) /* Handling opcode 110 insns. */ static int -thumb_record_ldm_stm_swi (insn_decode_record *thumb_insn_r) +thumb_record_ldm_stm_swi (insn_decode_record *thumb_insn_r) { - struct gdbarch_tdep *tdep = gdbarch_tdep (thumb_insn_r->gdbarch); + arm_gdbarch_tdep *tdep + = (arm_gdbarch_tdep *) gdbarch_tdep (thumb_insn_r->gdbarch); struct regcache *reg_cache = thumb_insn_r->regcache; uint32_t ret = 0; /* function return value: -1:record failure ; 0:success */ diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h index 705aa77..9012b9d 100644 --- a/gdb/arm-tdep.h +++ b/gdb/arm-tdep.h @@ -87,69 +87,70 @@ enum struct_return }; /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct arm_gdbarch_tdep : gdbarch_tdep { /* The ABI for this architecture. It should never be set to ARM_ABI_AUTO. */ - enum arm_abi_kind arm_abi; + enum arm_abi_kind arm_abi {}; - enum arm_float_model fp_model; /* Floating point calling conventions. */ + enum arm_float_model fp_model {}; /* Floating point calling conventions. */ - bool have_fpa_registers; /* Does the target report the FPA registers? */ - bool have_wmmx_registers; /* Does the target report the WMMX registers? */ + bool have_fpa_registers = false; /* Does the target report the FPA registers? */ + bool have_wmmx_registers = false; /* Does the target report the WMMX registers? */ /* The number of VFP registers reported by the target. It is zero if VFP registers are not supported. */ - int vfp_register_count; - bool have_s_pseudos; /* Are we synthesizing the single precision + int vfp_register_count = 0; + bool have_s_pseudos = false; /* Are we synthesizing the single precision VFP registers? */ - int s_pseudo_base; /* Register number for the first S pseudo + int s_pseudo_base = 0; /* Register number for the first S pseudo register. */ - int s_pseudo_count; /* Number of S pseudo registers. */ - bool have_q_pseudos; /* Are we synthesizing the quad precision + int s_pseudo_count = 0; /* Number of S pseudo registers. */ + bool have_q_pseudos = false; /* Are we synthesizing the quad precision Q (NEON or MVE) registers? Requires have_s_pseudos. */ - int q_pseudo_base; /* Register number for the first quad + int q_pseudo_base = 0; /* Register number for the first quad precision pseudo register. */ - int q_pseudo_count; /* Number of quad precision pseudo + int q_pseudo_count = 0; /* Number of quad precision pseudo registers. */ - bool have_neon; /* Do we have a NEON unit? */ + bool have_neon = false; /* Do we have a NEON unit? */ - bool have_mve; /* Do we have a MVE extension? */ - int mve_vpr_regnum; /* MVE VPR register number. */ - int mve_pseudo_base; /* Number of the first MVE pseudo register. */ - int mve_pseudo_count; /* Total number of MVE pseudo registers. */ + bool have_mve = false; /* Do we have a MVE extension? */ + int mve_vpr_regnum = 0; /* MVE VPR register number. */ + int mve_pseudo_base = 0; /* Number of the first MVE pseudo register. */ + int mve_pseudo_count = 0; /* Total number of MVE pseudo registers. */ - bool is_m; /* Does the target follow the "M" profile. */ - CORE_ADDR lowest_pc; /* Lowest address at which instructions + bool is_m = false; /* Does the target follow the "M" profile. */ + CORE_ADDR lowest_pc = 0; /* Lowest address at which instructions will appear. */ - const gdb_byte *arm_breakpoint; /* Breakpoint pattern for an ARM insn. */ - int arm_breakpoint_size; /* And its size. */ - const gdb_byte *thumb_breakpoint; /* Breakpoint pattern for a Thumb insn. */ - int thumb_breakpoint_size; /* And its size. */ + const gdb_byte *arm_breakpoint = nullptr; /* Breakpoint pattern for an ARM insn. */ + int arm_breakpoint_size = 0; /* And its size. */ + const gdb_byte *thumb_breakpoint = nullptr; /* Breakpoint pattern for a Thumb insn. */ + int thumb_breakpoint_size = 0; /* And its size. */ /* If the Thumb breakpoint is an undefined instruction (which is affected by IT blocks) rather than a BKPT instruction (which is not), then we need a 32-bit Thumb breakpoint to preserve the instruction count in IT blocks. */ - const gdb_byte *thumb2_breakpoint; - int thumb2_breakpoint_size; + const gdb_byte *thumb2_breakpoint = nullptr; + int thumb2_breakpoint_size = 0; - int jb_pc; /* Offset to PC value in jump buffer. + int jb_pc = 0; /* Offset to PC value in jump buffer. If this is negative, longjmp support will be disabled. */ - size_t jb_elt_size; /* And the size of each entry in the buf. */ + size_t jb_elt_size = 0; /* And the size of each entry in the buf. */ /* Convention for returning structures. */ - enum struct_return struct_return; + enum struct_return struct_return {}; /* ISA-specific data types. */ - struct type *arm_ext_type; - struct type *neon_double_type; - struct type *neon_quad_type; + struct type *arm_ext_type = nullptr; + struct type *neon_double_type = nullptr; + struct type *neon_quad_type = nullptr; /* syscall record. */ - int (*arm_syscall_record) (struct regcache *regcache, unsigned long svc_number); + int (*arm_syscall_record) (struct regcache *regcache, + unsigned long svc_number) = nullptr; }; /* Structures used for displaced stepping. */ diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c index f81a054..46cf835 100644 --- a/gdb/arm-wince-tdep.c +++ b/gdb/arm-wince-tdep.c @@ -115,7 +115,7 @@ arm_wince_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) static void arm_wince_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + arm_gdbarch_tdep *tdep = (arm_gdbarch_tdep *) gdbarch_tdep (gdbarch); windows_init_abi (info, gdbarch); diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index ea259b9..0db1986 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -188,18 +188,18 @@ struct avr_unwind_cache trad_frame_saved_reg *saved_regs; }; -struct gdbarch_tdep +struct avr_gdbarch_tdep : gdbarch_tdep { /* Number of bytes stored to the stack by call instructions. 2 bytes for avr1-5 and avrxmega1-5, 3 bytes for avr6 and avrxmega6-7. */ - int call_length; + int call_length = 0; /* Type for void. */ - struct type *void_type; + struct type *void_type = nullptr; /* Type for a function returning void. */ - struct type *func_void_type; + struct type *func_void_type = nullptr; /* Type for a pointer to a function. Used for the type of PC. */ - struct type *pc_type; + struct type *pc_type = nullptr; }; /* Lookup the name of a register given it's number. */ @@ -230,10 +230,14 @@ avr_register_type (struct gdbarch *gdbarch, int reg_nr) { if (reg_nr == AVR_PC_REGNUM) return builtin_type (gdbarch)->builtin_uint32; + + avr_gdbarch_tdep *tdep = (avr_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (reg_nr == AVR_PSEUDO_PC_REGNUM) - return gdbarch_tdep (gdbarch)->pc_type; + return tdep->pc_type; + if (reg_nr == AVR_SP_REGNUM) return builtin_type (gdbarch)->builtin_data_ptr; + return builtin_type (gdbarch)->builtin_uint8; } @@ -745,13 +749,13 @@ avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, gdb_assert (vpc < AVR_MAX_PROLOGUE_SIZE); /* Handle static small stack allocation using rcall or push. */ - + avr_gdbarch_tdep *tdep = (avr_gdbarch_tdep *) gdbarch_tdep (gdbarch); while (scan_stage == 1 && vpc < len) { insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order); if (insn == 0xd000) /* rcall .+0 */ { - info->size += gdbarch_tdep (gdbarch)->call_length; + info->size += tdep->call_length; vpc += 2; } else if (insn == 0x920f || insn == 0x921f) /* push r0 or push r1 */ @@ -984,7 +988,6 @@ avr_frame_unwind_cache (struct frame_info *this_frame, ULONGEST this_base; struct avr_unwind_cache *info; struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int i; if (*this_prologue_cache) @@ -1049,7 +1052,7 @@ avr_frame_unwind_cache (struct frame_info *this_frame, /* The previous frame's SP needed to be computed. Save the computed value. */ - tdep = gdbarch_tdep (gdbarch); + avr_gdbarch_tdep *tdep = (avr_gdbarch_tdep *) gdbarch_tdep (gdbarch); info->saved_regs[AVR_SP_REGNUM].set_value (info->prev_sp - 1 + tdep->call_length); @@ -1131,7 +1134,7 @@ avr_frame_prev_register (struct frame_info *this_frame, int i; gdb_byte buf[3]; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + avr_gdbarch_tdep *tdep = (avr_gdbarch_tdep *) gdbarch_tdep (gdbarch); read_memory (info->saved_regs[AVR_PC_REGNUM].addr (), buf, tdep->call_length); @@ -1273,7 +1276,8 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { int i; gdb_byte buf[3]; - int call_length = gdbarch_tdep (gdbarch)->call_length; + avr_gdbarch_tdep *tdep = (avr_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int call_length = tdep->call_length; CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr); int regnum = AVR_ARGN_REGNUM; struct stack_item *si = NULL; @@ -1424,7 +1428,6 @@ static struct gdbarch * avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; struct gdbarch_list *best_arch; int call_length; @@ -1456,12 +1459,15 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) best_arch != NULL; best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) { - if (gdbarch_tdep (best_arch->gdbarch)->call_length == call_length) + avr_gdbarch_tdep *tdep + = (avr_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch); + + if (tdep->call_length == call_length) return best_arch->gdbarch; } /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + avr_gdbarch_tdep *tdep = new avr_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->call_length = call_length; diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index d381f92..355f9f4 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -766,7 +766,8 @@ bfin_frame_align (struct gdbarch *gdbarch, CORE_ADDR address) enum bfin_abi bfin_abi (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->bfin_abi; + bfin_gdbarch_tdep *tdep = (bfin_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->bfin_abi; } /* Initialize the current architecture based on INFO. If possible, @@ -779,7 +780,6 @@ bfin_abi (struct gdbarch *gdbarch) static struct gdbarch * bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; enum bfin_abi abi; @@ -791,12 +791,16 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if (gdbarch_tdep (arches->gdbarch)->bfin_abi != abi) + bfin_gdbarch_tdep *tdep + = (bfin_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->bfin_abi != abi) continue; + return arches->gdbarch; } - tdep = XCNEW (struct gdbarch_tdep); + bfin_gdbarch_tdep *tdep = new bfin_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->bfin_abi = abi; diff --git a/gdb/bfin-tdep.h b/gdb/bfin-tdep.h index 309d4f4..70a1854 100644 --- a/gdb/bfin-tdep.h +++ b/gdb/bfin-tdep.h @@ -94,10 +94,10 @@ enum bfin_abi }; /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct bfin_gdbarch_tdep : gdbarch_tdep { /* Which ABI is in use? */ - enum bfin_abi bfin_abi; + enum bfin_abi bfin_abi {}; }; /* Return the Blackfin ABI associated with GDBARCH. */ diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c index e520d5d..b2cd913 100644 --- a/gdb/bpf-tdep.c +++ b/gdb/bpf-tdep.c @@ -57,7 +57,7 @@ enum bpf_regnum #define BPF_NUM_REGS (BPF_PC_REGNUM + 1) /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct bpf_gdbarch_tdep : gdbarch_tdep { }; @@ -321,7 +321,7 @@ bpf_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep); + bpf_gdbarch_tdep *tdep = new bpf_gdbarch_tdep; struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); /* Information about registers, etc. */ diff --git a/gdb/cris-linux-tdep.c b/gdb/cris-linux-tdep.c index 68a12db..e7dbded 100644 --- a/gdb/cris-linux-tdep.c +++ b/gdb/cris-linux-tdep.c @@ -33,7 +33,7 @@ static void cris_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 6b5dfc3..691cad8 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -313,7 +313,7 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct cris_unwind_cache *info; CORE_ADDR addr; @@ -450,7 +450,7 @@ static int crisv32_single_step_through_delay (struct gdbarch *gdbarch, struct frame_info *this_frame) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST erp; int ret = 0; @@ -695,7 +695,7 @@ cris_frame_unwind_cache (struct frame_info *this_frame, void **this_prologue_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct cris_unwind_cache *info; if ((*this_prologue_cache)) @@ -1333,7 +1333,7 @@ crisv32_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame, static CORE_ADDR cris_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR func_addr, func_end; struct symtab_and_line sal; CORE_ADDR pc_after_prologue; @@ -1368,7 +1368,7 @@ cris_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) static const gdb_byte * cris_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); static unsigned char break8_insn[] = {0x38, 0xe9}; static unsigned char break15_insn[] = {0x3f, 0xe9}; @@ -1387,7 +1387,7 @@ static int cris_spec_reg_applicable (struct gdbarch *gdbarch, struct cris_spec_reg spec_reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned int version = tdep->cris_version; switch (spec_reg.applicable_version) @@ -3766,7 +3766,7 @@ cris_supply_gregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); int i; const cris_elf_greg_t *regp = static_cast(gregs); @@ -3860,7 +3860,7 @@ Makes GDB use the NRP register instead of the ERP register in certain cases."), static void cris_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + cris_gdbarch_tdep *tdep = (cris_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep != NULL) { fprintf_unfiltered (file, "cris_dump_tdep: tdep->cris_version = %i\n", @@ -3914,7 +3914,6 @@ static struct gdbarch * cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; unsigned int cris_version; if (usr_cmd_cris_version_valid) @@ -3940,17 +3939,17 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if ((gdbarch_tdep (arches->gdbarch)->cris_version - == usr_cmd_cris_version) - && (gdbarch_tdep (arches->gdbarch)->cris_mode - == usr_cmd_cris_mode) - && (gdbarch_tdep (arches->gdbarch)->cris_dwarf2_cfi - == usr_cmd_cris_dwarf2_cfi)) + cris_gdbarch_tdep *tdep + = (cris_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->cris_version == usr_cmd_cris_version + && tdep->cris_mode == usr_cmd_cris_mode + && tdep->cris_dwarf2_cfi == usr_cmd_cris_dwarf2_cfi) return arches->gdbarch; } /* No matching architecture was found. Create a new one. */ - tdep = XCNEW (struct gdbarch_tdep); + cris_gdbarch_tdep *tdep = new cris_gdbarch_tdep; info.byte_order = BFD_ENDIAN_LITTLE; gdbarch = gdbarch_alloc (&info, tdep); diff --git a/gdb/cris-tdep.h b/gdb/cris-tdep.h index d898f4d..9b62294 100644 --- a/gdb/cris-tdep.h +++ b/gdb/cris-tdep.h @@ -24,11 +24,11 @@ #define CRIS_TDEP_H /* CRIS architecture specific information. */ -struct gdbarch_tdep +struct cris_gdbarch_tdep : gdbarch_tdep { - unsigned int cris_version; - const char *cris_mode; - int cris_dwarf2_cfi; + unsigned int cris_version = 0; + const char *cris_mode = nullptr; + int cris_dwarf2_cfi = 0; }; #endif /* CRIS_TDEP_H */ diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 8835aba..0b073fb 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -2164,7 +2164,6 @@ static struct gdbarch * csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* Find a candidate among the list of pre-declared architectures. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -2173,7 +2172,7 @@ csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + csky_gdbarch_tdep *tdep = new csky_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Target data types. */ diff --git a/gdb/csky-tdep.h b/gdb/csky-tdep.h index 7fc1a92..d690e8f 100644 --- a/gdb/csky-tdep.h +++ b/gdb/csky-tdep.h @@ -29,7 +29,7 @@ enum lr_type_t }; /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct csky_gdbarch_tdep : gdbarch_tdep { /* This is Unused. */ }; diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index e105c27..c74ea68 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -67,32 +67,33 @@ struct frv_unwind_cache /* was struct frame_extra_info */ of structures, each of which gives all the necessary info for one register. Don't stick parallel arrays in here --- that's so Fortran. */ -struct gdbarch_tdep +struct frv_gdbarch_tdep : gdbarch_tdep { /* Which ABI is in use? */ - enum frv_abi frv_abi; + enum frv_abi frv_abi {}; /* How many general-purpose registers does this variant have? */ - int num_gprs; + int num_gprs = 0; /* How many floating-point registers does this variant have? */ - int num_fprs; + int num_fprs = 0; /* How many hardware watchpoints can it support? */ - int num_hw_watchpoints; + int num_hw_watchpoints = 0; /* How many hardware breakpoints can it support? */ - int num_hw_breakpoints; + int num_hw_breakpoints = 0; /* Register names. */ - const char **register_names; + const char **register_names = nullptr; }; /* Return the FR-V ABI associated with GDBARCH. */ enum frv_abi frv_abi (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->frv_abi; + frv_gdbarch_tdep *tdep = (frv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->frv_abi; } /* Fetch the interpreter and executable loadmap addresses (for shared @@ -128,13 +129,12 @@ frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr, /* Allocate a new variant structure, and set up default values for all the fields. */ -static struct gdbarch_tdep * +static frv_gdbarch_tdep * new_variant (void) { - struct gdbarch_tdep *var; int r; - var = XCNEW (struct gdbarch_tdep); + frv_gdbarch_tdep *var = new frv_gdbarch_tdep; var->frv_abi = FRV_ABI_EABI; var->num_gprs = 64; @@ -219,7 +219,7 @@ new_variant (void) /* Indicate that the variant VAR has NUM_GPRS general-purpose registers, and fill in the names array appropriately. */ static void -set_variant_num_gprs (struct gdbarch_tdep *var, int num_gprs) +set_variant_num_gprs (frv_gdbarch_tdep *var, int num_gprs) { int r; @@ -238,7 +238,7 @@ set_variant_num_gprs (struct gdbarch_tdep *var, int num_gprs) /* Indicate that the variant VAR has NUM_FPRS floating-point registers, and fill in the names array appropriately. */ static void -set_variant_num_fprs (struct gdbarch_tdep *var, int num_fprs) +set_variant_num_fprs (frv_gdbarch_tdep *var, int num_fprs) { int r; @@ -254,7 +254,7 @@ set_variant_num_fprs (struct gdbarch_tdep *var, int num_fprs) } static void -set_variant_abi_fdpic (struct gdbarch_tdep *var) +set_variant_abi_fdpic (frv_gdbarch_tdep *var) { var->frv_abi = FRV_ABI_FDPIC; var->register_names[fdpic_loadmap_exec_regnum] = xstrdup ("loadmap_exec"); @@ -263,7 +263,7 @@ set_variant_abi_fdpic (struct gdbarch_tdep *var) } static void -set_variant_scratch_registers (struct gdbarch_tdep *var) +set_variant_scratch_registers (frv_gdbarch_tdep *var) { var->register_names[scr0_regnum] = xstrdup ("scr0"); var->register_names[scr1_regnum] = xstrdup ("scr1"); @@ -276,10 +276,12 @@ frv_register_name (struct gdbarch *gdbarch, int reg) { if (reg < 0) return "?toosmall?"; + if (reg >= frv_num_regs + frv_num_pseudo_regs) return "?toolarge?"; - return gdbarch_tdep (gdbarch)->register_names[reg]; + frv_gdbarch_tdep *tdep = (frv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->register_names[reg]; } @@ -1439,7 +1441,6 @@ static struct gdbarch * frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *var; int elf_flags = 0; /* Check to see if we've already built an appropriate architecture @@ -1449,7 +1450,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Select the right tdep structure for this variant. */ - var = new_variant (); + frv_gdbarch_tdep *var = new_variant (); switch (info.bfd_arch_info->mach) { case bfd_mach_frv: diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index ff03acb..eec800c 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -109,7 +109,10 @@ static struct type * ft32_register_type (struct gdbarch *gdbarch, int reg_nr) { if (reg_nr == FT32_PC_REGNUM) - return gdbarch_tdep (gdbarch)->pc_type; + { + ft32_gdbarch_tdep *tdep = (ft32_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->pc_type; + } else if (reg_nr == FT32_SP_REGNUM || reg_nr == FT32_FP_REGNUM) return builtin_type (gdbarch)->builtin_data_ptr; else @@ -559,7 +562,6 @@ static struct gdbarch * ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; struct type *void_type; struct type *func_void_type; @@ -569,7 +571,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + ft32_gdbarch_tdep *tdep = new ft32_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Create a type for PC. We can't use builtin types here, as they may not diff --git a/gdb/ft32-tdep.h b/gdb/ft32-tdep.h index 0303801..c32f646 100644 --- a/gdb/ft32-tdep.h +++ b/gdb/ft32-tdep.h @@ -20,10 +20,10 @@ #ifndef FT32_TDEP_H #define FT32_TDEP_H -struct gdbarch_tdep +struct ft32_gdbarch_tdep : gdbarch_tdep { /* Type for a pointer to a function. Used for the type of PC. */ - struct type *pc_type; + struct type *pc_type = nullptr; }; #endif /* FT32_TDEP_H */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 979159b..f73d562 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -62,6 +62,8 @@ struct inferior; #include "regcache.h" +struct gdbarch_tdep {}; + /* The architecture associated with the inferior through the connection to the target. diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 39a99d0..829f241 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -1333,6 +1333,8 @@ struct inferior; #include "regcache.h" +struct gdbarch_tdep {}; + /* The architecture associated with the inferior through the connection to the target. diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c index c68aaf1..f4567b4 100644 --- a/gdb/hppa-bsd-tdep.c +++ b/gdb/hppa-bsd-tdep.c @@ -118,7 +118,7 @@ hppabsd_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, void hppabsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* OpenBSD and NetBSD have a 64-bit 'long double'. */ set_gdbarch_long_double_bit (gdbarch, 64); diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c index 52c642f..1dd6993 100644 --- a/gdb/hppa-linux-tdep.c +++ b/gdb/hppa-linux-tdep.c @@ -476,7 +476,7 @@ hppa_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", 80 * tdep->bytes_per_address, 80 * tdep->bytes_per_address, &hppa_linux_regset, NULL, cb_data); @@ -486,7 +486,7 @@ hppa_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, static void hppa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 344022c..d64f9f7 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -259,6 +259,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table, if (size > 0) { struct gdbarch *gdbarch = objfile->arch (); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned long tmp; unsigned i; char *buf = (char *) alloca (size); @@ -270,7 +271,7 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table, Note that when loading a shared library (text_offset != 0) the unwinds are already relative to the text_offset that will be passed in. */ - if (gdbarch_tdep (gdbarch)->is_elf && text_offset == 0) + if (tdep->is_elf && text_offset == 0) { low_text_segment_address = -1; @@ -280,9 +281,9 @@ internalize_unwinds (struct objfile *objfile, struct unwind_table_entry *table, text_offset = low_text_segment_address; } - else if (gdbarch_tdep (gdbarch)->solib_get_text_base) + else if (tdep->solib_get_text_base) { - text_offset = gdbarch_tdep (gdbarch)->solib_get_text_base (objfile); + text_offset = tdep->solib_get_text_base (objfile); } bfd_get_section_contents (objfile->obfd, section, buf, 0, size); @@ -730,7 +731,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Global pointer (r19) of the function we are trying to call. */ CORE_ADDR gp; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); for (write_pass = 0; write_pass < 2; write_pass++) { @@ -967,7 +968,7 @@ hppa64_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); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int i, offset = 0; CORE_ADDR gp; @@ -2253,9 +2254,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache) } { - struct gdbarch_tdep *tdep; - - tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->unwind_adjust_stub) tdep->unwind_adjust_stub (this_frame, cache->base, cache->saved_regs); @@ -2485,7 +2484,7 @@ hppa_stub_unwind_sniffer (const struct frame_unwind *self, { CORE_ADDR pc = get_frame_address_in_block (this_frame); struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (pc == 0 || (tdep->in_solib_call_trampoline != NULL @@ -3029,7 +3028,6 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) static struct gdbarch * hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; /* find a candidate among the list of pre-declared architectures. */ @@ -3038,7 +3036,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return (arches->gdbarch); /* If none found, then allocate and initialize one. */ - tdep = XCNEW (struct gdbarch_tdep); + hppa_gdbarch_tdep *tdep = new hppa_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Determine from the bfd_arch_info structure if we are dealing with @@ -3162,7 +3160,7 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void hppa_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + hppa_gdbarch_tdep *tdep = (hppa_gdbarch_tdep *) gdbarch_tdep (gdbarch); fprintf_unfiltered (file, "bytes_per_address = %d\n", tdep->bytes_per_address); diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h index d033c14..7298881 100644 --- a/gdb/hppa-tdep.h +++ b/gdb/hppa-tdep.h @@ -20,6 +20,8 @@ #ifndef HPPA_TDEP_H #define HPPA_TDEP_H +#include "gdbarch.h" + struct trad_frame_saved_reg; struct objfile; struct so_list; @@ -82,24 +84,25 @@ enum hppa_regnum #define HPPA_INSN_SIZE 4 /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct hppa_gdbarch_tdep : gdbarch_tdep { /* The number of bytes in an address. For now, this field is designed to allow us to differentiate hppa32 from hppa64 targets. */ - int bytes_per_address; + int bytes_per_address = 0; /* Is this an ELF target? This can be 64-bit HP-UX, or a 32/64-bit GNU/Linux system. */ - int is_elf; + int is_elf = 0; /* Given a function address, try to find the global pointer for the corresponding shared object. */ - CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *); + CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *) = nullptr; /* For shared libraries, each call goes through a small piece of trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates to nonzero if we are currently stopped in one of these. */ - int (*in_solib_call_trampoline) (struct gdbarch *gdbarch, CORE_ADDR pc); + int (*in_solib_call_trampoline) (struct gdbarch *gdbarch, + CORE_ADDR pc) = nullptr; /* For targets that support multiple spaces, we may have additional stubs in the return path. These stubs are internal to the ABI, and users are @@ -107,14 +110,14 @@ struct gdbarch_tdep adjust the pc to the real caller. This improves the behavior of commands that traverse frames such as "up" and "finish". */ void (*unwind_adjust_stub) (struct frame_info *this_frame, CORE_ADDR base, - trad_frame_saved_reg *saved_regs); + trad_frame_saved_reg *saved_regs) = nullptr; /* These are solib-dependent methods. They are really HPUX only, but we don't have a HPUX-specific tdep vector at the moment. */ - CORE_ADDR (*solib_thread_start_addr) (struct so_list *so); - CORE_ADDR (*solib_get_got_by_pc) (CORE_ADDR addr); - CORE_ADDR (*solib_get_solib_by_pc) (CORE_ADDR addr); - CORE_ADDR (*solib_get_text_base) (struct objfile *objfile); + CORE_ADDR (*solib_thread_start_addr) (struct so_list *so) = nullptr; + CORE_ADDR (*solib_get_got_by_pc) (CORE_ADDR addr) = nullptr; + CORE_ADDR (*solib_get_solib_by_pc) (CORE_ADDR addr) = nullptr; + CORE_ADDR (*solib_get_text_base) (struct objfile *objfile) = nullptr; }; /* diff --git a/gdb/i386-bsd-tdep.c b/gdb/i386-bsd-tdep.c index fb5fcaa..7bddc7a 100644 --- a/gdb/i386-bsd-tdep.c +++ b/gdb/i386-bsd-tdep.c @@ -74,7 +74,7 @@ int i386bsd_sc_reg_offset[] = void i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->jb_pc_offset = 0; diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index c038d8b..900a0a6 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -156,7 +156,7 @@ i386_darwin_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); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte buf[4]; int i; @@ -248,7 +248,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, struct value *function, static void i386_darwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* We support the SSE registers. */ tdep->num_xmm_regs = I386_NUM_XREGS - 1; diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c index 1039724..01db76f 100644 --- a/gdb/i386-fbsd-tdep.c +++ b/gdb/i386-fbsd-tdep.c @@ -308,7 +308,7 @@ i386fbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL, cb_data); @@ -327,7 +327,7 @@ static CORE_ADDR i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct regcache *regcache; if (tdep->fsbase_regnum == -1) @@ -349,7 +349,7 @@ i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, static void i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Obviously FreeBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); @@ -418,7 +418,7 @@ int i386fbsd4_sc_reg_offset[] = static void i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/i386-gnu-tdep.c b/gdb/i386-gnu-tdep.c index 33ccd3b..1f5e5f7 100644 --- a/gdb/i386-gnu-tdep.c +++ b/gdb/i386-gnu-tdep.c @@ -173,7 +173,7 @@ static int i386gnu_gregset_reg_offset[] = static void i386gnu_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* GNU uses ELF. */ i386_elf_init_abi (info, gdbarch); diff --git a/gdb/i386-go32-tdep.c b/gdb/i386-go32-tdep.c index 7b9a4ca..31aef42 100644 --- a/gdb/i386-go32-tdep.c +++ b/gdb/i386-go32-tdep.c @@ -26,7 +26,7 @@ static void i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* DJGPP doesn't have any special frames for signal handlers. */ tdep->sigtramp_p = NULL; diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 1c065ee..898b73f 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -762,7 +762,7 @@ i386_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", 68, 68, &i386_gregset, NULL, cb_data); @@ -824,7 +824,7 @@ i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, static void i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct target_desc *tdesc = info.target_desc; struct tdesc_arch_data *tdesc_data = info.tdesc_data; const struct tdesc_feature *feature; diff --git a/gdb/i386-netbsd-tdep.c b/gdb/i386-netbsd-tdep.c index 76dcc4d..9915921 100644 --- a/gdb/i386-netbsd-tdep.c +++ b/gdb/i386-netbsd-tdep.c @@ -372,7 +372,7 @@ i386nbsd_sigtramp_cache_init (const struct tramp_frame *self, static void i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Obviously NetBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); @@ -407,7 +407,7 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) static void i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* It's still NetBSD. */ i386nbsd_init_abi (info, gdbarch); diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c index 11e05e3..4d443e6 100644 --- a/gdb/i386-nto-tdep.c +++ b/gdb/i386-nto-tdep.c @@ -77,7 +77,7 @@ static void i386nto_supply_gregset (struct regcache *regcache, char *gpregs) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (tdep->gregset_reg_offset == i386nto_gregset_reg_offset); i386_gregset.supply_regset (&i386_gregset, regcache, -1, @@ -126,7 +126,7 @@ static int i386nto_register_area (struct gdbarch *gdbarch, int regno, int regset, unsigned *off) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); *off = 0; if (regset == NTO_REG_GENERAL) @@ -315,7 +315,7 @@ init_i386nto_ops (void) static void i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); static struct target_so_ops nto_svr4_so_ops; /* Deal with our strange signals. */ diff --git a/gdb/i386-obsd-tdep.c b/gdb/i386-obsd-tdep.c index 3f5606d..ad0a7c8 100644 --- a/gdb/i386-obsd-tdep.c +++ b/gdb/i386-obsd-tdep.c @@ -407,7 +407,7 @@ static const struct frame_unwind i386obsd_trapframe_unwind = { static void i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Obviously OpenBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c index acc85ee..e06ef36 100644 --- a/gdb/i386-sol2-tdep.c +++ b/gdb/i386-sol2-tdep.c @@ -65,7 +65,7 @@ i386_sol2_mcontext_addr (struct frame_info *this_frame) static void i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Solaris is SVR4-based. */ i386_svr4_init_abi (info, gdbarch); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f65a074..ce18cf3 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -167,7 +167,7 @@ const int num_lower_zmm_regs = 16; static int i386_mmx_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int mm0_regnum = tdep->mm0_regnum; if (mm0_regnum < 0) @@ -182,7 +182,7 @@ i386_mmx_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_byte_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); regnum -= tdep->al_regnum; return regnum >= 0 && regnum < tdep->num_byte_regs; @@ -193,7 +193,7 @@ i386_byte_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_word_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); regnum -= tdep->ax_regnum; return regnum >= 0 && regnum < tdep->num_word_regs; @@ -204,7 +204,7 @@ i386_word_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int eax_regnum = tdep->eax_regnum; if (eax_regnum < 0) @@ -219,7 +219,7 @@ i386_dword_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int zmm0h_regnum = tdep->zmm0h_regnum; if (zmm0h_regnum < 0) @@ -232,7 +232,7 @@ i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int zmm0_regnum = tdep->zmm0_regnum; if (zmm0_regnum < 0) @@ -245,7 +245,7 @@ i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_k_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int k0_regnum = tdep->k0_regnum; if (k0_regnum < 0) @@ -258,7 +258,7 @@ i386_k_regnum_p (struct gdbarch *gdbarch, int regnum) static int i386_ymmh_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ymm0h_regnum = tdep->ymm0h_regnum; if (ymm0h_regnum < 0) @@ -273,7 +273,7 @@ i386_ymmh_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ymm0_regnum = tdep->ymm0_regnum; if (ymm0_regnum < 0) @@ -286,7 +286,7 @@ i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum) static int i386_ymmh_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ymm16h_regnum = tdep->ymm16h_regnum; if (ymm16h_regnum < 0) @@ -299,7 +299,7 @@ i386_ymmh_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ymm16_regnum = tdep->ymm16_regnum; if (ymm16_regnum < 0) @@ -314,7 +314,7 @@ i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int bnd0_regnum = tdep->bnd0_regnum; if (bnd0_regnum < 0) @@ -329,7 +329,7 @@ i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int num_xmm_regs = I387_NUM_XMM_REGS (tdep); if (num_xmm_regs == 0) @@ -344,7 +344,7 @@ i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_xmm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int num_xmm_avx512_regs = I387_NUM_XMM_AVX512_REGS (tdep); if (num_xmm_avx512_regs == 0) @@ -357,7 +357,7 @@ i386_xmm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum) static int i386_mxcsr_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_NUM_XMM_REGS (tdep) == 0) return 0; @@ -370,7 +370,7 @@ i386_mxcsr_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_fp_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_ST0_REGNUM (tdep) < 0) return 0; @@ -382,7 +382,7 @@ i386_fp_regnum_p (struct gdbarch *gdbarch, int regnum) int i386_fpc_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_ST0_REGNUM (tdep) < 0) return 0; @@ -396,7 +396,7 @@ i386_fpc_regnum_p (struct gdbarch *gdbarch, int regnum) static int i386_bndr_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_BND0R_REGNUM (tdep) < 0) return 0; @@ -410,7 +410,7 @@ i386_bndr_regnum_p (struct gdbarch *gdbarch, int regnum) static int i386_mpx_ctrl_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_BNDCFGU_REGNUM (tdep) < 0) return 0; @@ -424,7 +424,7 @@ i386_mpx_ctrl_regnum_p (struct gdbarch *gdbarch, int regnum) bool i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int pkru_regnum = tdep->pkru_regnum; if (pkru_regnum < 0) @@ -460,7 +460,7 @@ i386_register_name (struct gdbarch *gdbarch, int regnum) const char * i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_bnd_regnum_p (gdbarch, regnum)) return i386_bnd_names[regnum - tdep->bnd0_regnum]; if (i386_mmx_regnum_p (gdbarch, regnum)) @@ -483,7 +483,7 @@ i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum) static int i386_dbx_reg_to_regnum (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* This implements what GCC calls the "default" register map (dbx_register_map[]). */ @@ -530,7 +530,7 @@ i386_dbx_reg_to_regnum (struct gdbarch *gdbarch, int reg) static int i386_svr4_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* This implements the GCC register map that tries to be compatible with the SVR4 C compiler for DWARF (svr4_dbx_register_map[]). */ @@ -2432,7 +2432,7 @@ static struct i386_frame_cache * i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct i386_frame_cache *cache; CORE_ADDR addr; @@ -2521,7 +2521,8 @@ i386_sigtramp_frame_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); /* We shouldn't even bother if we don't have a sigcontext_addr handler. */ @@ -2608,7 +2609,8 @@ i386_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) CORE_ADDR sp, jb_addr; struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset; + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int jb_pc_offset = tdep->jb_pc_offset; /* If JB_PC_OFFSET is -1, we have no way to find out where the longjmp will land. */ @@ -2815,7 +2817,7 @@ static void i386_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *valbuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int len = TYPE_LENGTH (type); gdb_byte buf[I386_MAX_REGISTER_SIZE]; @@ -2873,7 +2875,7 @@ static void i386_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int len = TYPE_LENGTH (type); if (type->code () == TYPE_CODE_FLT) @@ -2952,7 +2954,7 @@ static const char *struct_convention = default_struct_convention; static int i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum type_code code = type->code (); int len = TYPE_LENGTH (type); @@ -3054,7 +3056,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, struct type * i387_ext_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->i387_ext_type) { @@ -3072,7 +3074,7 @@ i387_ext_type (struct gdbarch *gdbarch) static struct type * i386_bnd_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->i386_bnd_type) @@ -3108,7 +3110,7 @@ i386_bnd_type (struct gdbarch *gdbarch) static struct type * i386_zmm_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->i386_zmm_type) { @@ -3167,7 +3169,7 @@ i386_zmm_type (struct gdbarch *gdbarch) static struct type * i386_ymm_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->i386_ymm_type) { @@ -3224,7 +3226,7 @@ i386_ymm_type (struct gdbarch *gdbarch) static struct type * i386_mmx_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->i386_mmx_type) { @@ -3300,7 +3302,8 @@ i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum) static int i386_mmx_regnum_to_fp_regnum (readable_regcache *regcache, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); int mmxreg, fpreg; ULONGEST fstat; int tos; @@ -3341,7 +3344,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, } else { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_bnd_regnum_p (gdbarch, regnum)) { regnum -= tdep->bnd0_regnum; @@ -3531,7 +3534,7 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, } else { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_bnd_regnum_p (gdbarch, regnum)) { @@ -3639,7 +3642,7 @@ int i386_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (i386_mmx_regnum_p (gdbarch, regnum)) { @@ -3856,7 +3859,7 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); const gdb_byte *regs = (const gdb_byte *) gregs; int i; @@ -3881,7 +3884,7 @@ i386_collect_gregset (const struct regset *regset, int regnum, void *gregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte *regs = (gdb_byte *) gregs; int i; @@ -3904,7 +3907,7 @@ i386_supply_fpregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (len == I387_SIZEOF_FXSAVE) { @@ -3927,7 +3930,7 @@ i386_collect_fpregset (const struct regset *regset, int regnum, void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (len == I387_SIZEOF_FXSAVE) { @@ -3959,7 +3962,7 @@ i386_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL, cb_data); @@ -4464,7 +4467,7 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) void i386_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* System V Release 4 uses ELF. */ i386_elf_init_abi (info, gdbarch); @@ -4513,7 +4516,7 @@ int i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *group) { - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p, ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p, ymmh_avx512_regnum_p, bndr_regnum_p, bnd_regnum_p, zmm_regnum_p, zmmh_regnum_p, @@ -4958,7 +4961,7 @@ static int i386_record_floats (struct gdbarch *gdbarch, struct i386_record_s *ir, uint32_t iregnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); int i; /* Oza: Because of floating point insn push/pop of fpu stack is going to @@ -5029,7 +5032,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache, ULONGEST addr; gdb_byte buf[I386_MAX_REGISTER_SIZE]; struct i386_record_s ir; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); uint8_t rex_w = -1; uint8_t rex_r = 0; @@ -8191,7 +8194,7 @@ i386_floatformat_for_type (struct gdbarch *gdbarch, } static int -i386_validate_tdesc_p (struct gdbarch_tdep *tdep, +i386_validate_tdesc_p (i386_gdbarch_tdep *tdep, struct tdesc_arch_data *tdesc_data) { const struct target_desc *tdesc = tdep->tdesc; @@ -8393,7 +8396,6 @@ i386_type_align (struct gdbarch *gdbarch, struct type *type) static struct gdbarch * i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; const struct target_desc *tdesc; int mm0_regnum; @@ -8407,7 +8409,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. Assume i386 for now. */ - tdep = XCNEW (struct gdbarch_tdep); + i386_gdbarch_tdep *tdep = new i386_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* General-purpose registers. */ @@ -8651,7 +8653,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (!i386_validate_tdesc_p (tdep, tdesc_data.get ())) { - xfree (tdep); + delete tdep; gdbarch_free (gdbarch); return NULL; } @@ -8784,12 +8786,12 @@ static unsigned long i386_mpx_bd_base (void) { struct regcache *rcache; - struct gdbarch_tdep *tdep; ULONGEST ret; enum register_status regstatus; rcache = get_current_regcache (); - tdep = gdbarch_tdep (rcache->arch ()); + gdbarch *arch = rcache->arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); regstatus = regcache_raw_read_unsigned (rcache, tdep->bndcfgu_regnum, &ret); @@ -8802,7 +8804,8 @@ i386_mpx_bd_base (void) int i386_mpx_enabled (void) { - const struct gdbarch_tdep *tdep = gdbarch_tdep (get_current_arch ()); + gdbarch *arch = get_current_arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); const struct target_desc *tdesc = tdep->tdesc; return (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL); diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index ee7655e..8f1819b 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -57,206 +57,206 @@ enum struct_return }; /* i386 architecture specific information. */ -struct gdbarch_tdep +struct i386_gdbarch_tdep : gdbarch_tdep { /* General-purpose registers. */ - int *gregset_reg_offset; - int gregset_num_regs; - size_t sizeof_gregset; + int *gregset_reg_offset = 0; + int gregset_num_regs = 0; + size_t sizeof_gregset = 0; /* Floating-point registers. */ - size_t sizeof_fpregset; + size_t sizeof_fpregset = 0; /* Register number for %st(0). The register numbers for the other registers follow from this one. Set this to -1 to indicate the absence of an FPU. */ - int st0_regnum; + int st0_regnum = 0; /* Number of MMX registers. */ - int num_mmx_regs; + int num_mmx_regs = 0; /* Register number for %mm0. Set this to -1 to indicate the absence of MMX support. */ - int mm0_regnum; + int mm0_regnum = 0; /* Number of pseudo YMM registers. */ - int num_ymm_regs; + int num_ymm_regs = 0; /* Register number for %ymm0. Set this to -1 to indicate the absence of pseudo YMM register support. */ - int ymm0_regnum; + int ymm0_regnum = 0; /* Number of AVX512 OpMask registers (K-registers) */ - int num_k_regs; + int num_k_regs = 0; /* Register number for %k0. Set this to -1 to indicate the absence of AVX512 OpMask register support. */ - int k0_regnum; + int k0_regnum = 0; /* Number of pseudo ZMM registers ($zmm0-$zmm31). */ - int num_zmm_regs; + int num_zmm_regs = 0; /* Register number for %zmm0. Set this to -1 to indicate the absence of pseudo ZMM register support. */ - int zmm0_regnum; + int zmm0_regnum = 0; /* Number of byte registers. */ - int num_byte_regs; + int num_byte_regs = 0; /* Register pseudo number for %al. */ - int al_regnum; + int al_regnum = 0; /* Number of pseudo word registers. */ - int num_word_regs; + int num_word_regs = 0; /* Register number for %ax. */ - int ax_regnum; + int ax_regnum = 0; /* Number of pseudo dword registers. */ - int num_dword_regs; + int num_dword_regs = 0; /* Register number for %eax. Set this to -1 to indicate the absence of pseudo dword register support. */ - int eax_regnum; + int eax_regnum = 0; /* Number of core registers. */ - int num_core_regs; + int num_core_regs = 0; /* Number of SSE registers. */ - int num_xmm_regs; + int num_xmm_regs = 0; /* Number of SSE registers added in AVX512. */ - int num_xmm_avx512_regs; + int num_xmm_avx512_regs = 0; /* Register number of XMM16, the first XMM register added in AVX512. */ - int xmm16_regnum; + int xmm16_regnum = 0; /* Number of YMM registers added in AVX512. */ - int num_ymm_avx512_regs; + int num_ymm_avx512_regs = 0; /* Register number of YMM16, the first YMM register added in AVX512. */ - int ymm16_regnum; + int ymm16_regnum = 0; /* Bits of the extended control register 0 (the XFEATURE_ENABLED_MASK register), excluding the x87 bit, which are supported by this GDB. */ - uint64_t xcr0; + uint64_t xcr0 = 0; /* Offset of XCR0 in XSAVE extended state. */ - int xsave_xcr0_offset; + int xsave_xcr0_offset = 0; /* Register names. */ - const char * const *register_names; + const char * const *register_names = nullptr; /* Register number for %ymm0h. Set this to -1 to indicate the absence of upper YMM register support. */ - int ymm0h_regnum; + int ymm0h_regnum = 0; /* Upper YMM register names. Only used for tdesc_numbered_register. */ - const char * const *ymmh_register_names; + const char * const *ymmh_register_names = nullptr; /* Register number for %ymm16h. Set this to -1 to indicate the absence of support for YMM16-31. */ - int ymm16h_regnum; + int ymm16h_regnum = 0; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ - const char * const *ymm16h_register_names; + const char * const *ymm16h_register_names = nullptr; /* Register number for %bnd0r. Set this to -1 to indicate the absence bound registers. */ - int bnd0r_regnum; + int bnd0r_regnum = 0; /* Register number for pseudo register %bnd0. Set this to -1 to indicate the absence bound registers. */ - int bnd0_regnum; + int bnd0_regnum = 0; /* Register number for %bndcfgu. Set this to -1 to indicate the absence bound control registers. */ - int bndcfgu_regnum; + int bndcfgu_regnum = 0; /* MPX register names. Only used for tdesc_numbered_register. */ - const char * const *mpx_register_names; + const char * const *mpx_register_names = nullptr; /* Register number for %zmm0h. Set this to -1 to indicate the absence of ZMM_HI256 register support. */ - int zmm0h_regnum; + int zmm0h_regnum = 0; /* OpMask register names. */ - const char * const *k_register_names; + const char * const *k_register_names = nullptr; /* ZMM register names. Only used for tdesc_numbered_register. */ - const char * const *zmmh_register_names; + const char * const *zmmh_register_names = nullptr; /* XMM16-31 register names. Only used for tdesc_numbered_register. */ - const char * const *xmm_avx512_register_names; + const char * const *xmm_avx512_register_names = nullptr; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ - const char * const *ymm_avx512_register_names; + const char * const *ymm_avx512_register_names = nullptr; /* Number of PKEYS registers. */ - int num_pkeys_regs; + int num_pkeys_regs = 0; /* Register number for PKRU register. */ - int pkru_regnum; + int pkru_regnum = 0; /* PKEYS register names. */ - const char * const *pkeys_register_names; + const char * const *pkeys_register_names = nullptr; /* Register number for %fsbase. Set this to -1 to indicate the absence of segment base registers. */ - int fsbase_regnum; + int fsbase_regnum = 0; /* Target description. */ - const struct target_desc *tdesc; + const struct target_desc *tdesc = nullptr; /* Register group function. */ - gdbarch_register_reggroup_p_ftype *register_reggroup_p; + gdbarch_register_reggroup_p_ftype *register_reggroup_p = nullptr; /* Offset of saved PC in jmp_buf. */ - int jb_pc_offset; + int jb_pc_offset = 0; /* Convention for returning structures. */ - enum struct_return struct_return; + enum struct_return struct_return {}; /* Address range where sigtramp lives. */ - CORE_ADDR sigtramp_start; - CORE_ADDR sigtramp_end; + CORE_ADDR sigtramp_start = 0; + CORE_ADDR sigtramp_end = 0; /* Detect sigtramp. */ - int (*sigtramp_p) (struct frame_info *); + int (*sigtramp_p) (struct frame_info *) = nullptr; /* Get address of sigcontext for sigtramp. */ - CORE_ADDR (*sigcontext_addr) (struct frame_info *); + CORE_ADDR (*sigcontext_addr) (struct frame_info *) = nullptr; /* Offset of registers in `struct sigcontext'. */ - int *sc_reg_offset; - int sc_num_regs; + int *sc_reg_offset = 0; + int sc_num_regs = 0; /* Offset of saved PC and SP in `struct sigcontext'. Usage of these is deprecated, please use `sc_reg_offset' instead. */ - int sc_pc_offset; - int sc_sp_offset; + int sc_pc_offset = 0; + int sc_sp_offset = 0; /* ISA-specific data types. */ - struct type *i386_mmx_type; - struct type *i386_ymm_type; - struct type *i386_zmm_type; - struct type *i387_ext_type; - struct type *i386_bnd_type; + struct type *i386_mmx_type = nullptr; + struct type *i386_ymm_type = nullptr; + struct type *i386_zmm_type = nullptr; + struct type *i387_ext_type = nullptr; + struct type *i386_bnd_type = nullptr; /* Process record/replay target. */ /* The map for registers because the AMD64's registers order in GDB is not same as I386 instructions. */ - const int *record_regmap; + const int *record_regmap = nullptr; /* Parse intx80 args. */ - int (*i386_intx80_record) (struct regcache *regcache); + int (*i386_intx80_record) (struct regcache *regcache) = nullptr; /* Parse sysenter args. */ - int (*i386_sysenter_record) (struct regcache *regcache); + int (*i386_sysenter_record) (struct regcache *regcache) = nullptr; /* Parse syscall args. */ - int (*i386_syscall_record) (struct regcache *regcache); + int (*i386_syscall_record) (struct regcache *regcache) = nullptr; /* Regsets. */ - const struct regset *fpregset; + const struct regset *fpregset = nullptr; }; /* Floating-point registers. */ diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index b561d60..5ab1474 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -136,7 +136,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function, static void i386_windows_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); set_gdbarch_skip_trampoline_code (gdbarch, i386_windows_skip_trampoline_code); diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index cb1aa15..e5c7814 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -204,7 +204,7 @@ void i387_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame)); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST fctrl; int fctrl_p; ULONGEST fstat; @@ -440,7 +440,7 @@ void i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); const gdb_byte *regs = (const gdb_byte *) fsave; int i; @@ -494,7 +494,8 @@ i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave) void i387_collect_fsave (const struct regcache *regcache, int regnum, void *fsave) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); gdb_byte *regs = (gdb_byte *) fsave; int i; @@ -587,7 +588,8 @@ static int i387_tag (const gdb_byte *raw); void i387_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); const gdb_byte *regs = (const gdb_byte *) fxsave; int i; @@ -670,7 +672,8 @@ i387_supply_fxsave (struct regcache *regcache, int regnum, const void *fxsave) void i387_collect_fxsave (const struct regcache *regcache, int regnum, void *fxsave) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (arch); gdb_byte *regs = (gdb_byte *) fxsave; int i; @@ -903,7 +906,7 @@ i387_xsave_get_clear_bv (struct gdbarch *gdbarch, const void *xsave) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); const gdb_byte *regs = (const gdb_byte *) xsave; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Get `xstat_bv'. The supported bits in `xstat_bv' are 8 bytes. */ ULONGEST xstate_bv = extract_unsigned_integer (XSAVE_XSTATE_BV_ADDR (regs), @@ -923,7 +926,7 @@ i387_supply_xsave (struct regcache *regcache, int regnum, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); const gdb_byte *regs = (const gdb_byte *) xsave; int i; /* In 64-bit mode the split between "low" and "high" ZMM registers is at @@ -1346,7 +1349,7 @@ i387_collect_xsave (const struct regcache *regcache, int regnum, { struct gdbarch *gdbarch = regcache->arch (); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte *p, *regs = (gdb_byte *) xsave; gdb_byte raw[I386_MAX_REGISTER_SIZE]; ULONGEST initial_xstate_bv, clear_bv, xstate_bv = 0; @@ -1931,7 +1934,7 @@ i387_tag (const gdb_byte *raw) void i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST fstat; /* Set the top of the floating-point register stack to 7. The @@ -1954,7 +1957,7 @@ i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache) void i387_reset_bnd_regs (struct gdbarch *gdbarch, struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + i386_gdbarch_tdep *tdep = (i386_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (I387_BND0R_REGNUM (tdep) > 0) { diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c index 71767dd..cf062f1 100644 --- a/gdb/ia64-linux-tdep.c +++ b/gdb/ia64-linux-tdep.c @@ -216,7 +216,7 @@ ia64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, static void ia64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (gdbarch); static const char *const stap_register_prefixes[] = { "r", NULL }; static const char *const stap_register_indirection_prefixes[] = { "[", NULL }; diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index b6816cb..08c5d6a 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -310,7 +310,7 @@ static const struct floatformat *floatformats_ia64_ext[2] = static struct type * ia64_ext_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->ia64_ext_type) tdep->ia64_ext_type @@ -2177,7 +2177,7 @@ ia64_sigtramp_frame_init_saved_regs (struct frame_info *this_frame, struct ia64_frame_cache *cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->sigcontext_register_address) { @@ -2335,7 +2335,8 @@ ia64_sigtramp_frame_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, void **this_cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame)); + gdbarch *arch = get_frame_arch (this_frame); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (arch); if (tdep->pc_in_sigtramp) { CORE_ADDR pc = get_frame_pc (this_frame); @@ -3482,7 +3483,7 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch, static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch, CORE_ADDR faddr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR addr = 0; if (tdep->find_global_pointer_from_solib) @@ -3677,7 +3678,7 @@ ia64_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); + ia64_gdbarch_tdep *tdep = (ia64_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int argno; struct value *arg; @@ -3917,14 +3918,13 @@ static struct gdbarch * ia64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); if (arches != NULL) return arches->gdbarch; - tdep = XCNEW (struct gdbarch_tdep); + ia64_gdbarch_tdep *tdep = new ia64_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->size_of_register_frame = ia64_size_of_register_frame; diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h index 28bf446..82319d5 100644 --- a/gdb/ia64-tdep.h +++ b/gdb/ia64-tdep.h @@ -20,6 +20,8 @@ #ifndef IA64_TDEP_H #define IA64_TDEP_H +#include "gdbarch.h" + #ifdef HAVE_LIBUNWIND_IA64_H #include "libunwind-ia64.h" #include "ia64-libunwind-tdep.h" @@ -214,30 +216,33 @@ struct ia64_infcall_ops Should do nothing if this operation is not permitted by the OS. */ void (*allocate_new_rse_frame) (struct regcache *regcache, ULONGEST bsp, - int sof); + int sof) = nullptr; /* Store the argument stored in BUF into the appropriate location given the BSP and the SLOTNUM. */ void (*store_argument_in_slot) (struct regcache *regcache, CORE_ADDR bsp, - int slotnum, gdb_byte *buf); + int slotnum, gdb_byte *buf) = nullptr; /* For targets where we cannot call the function directly, store the address of the function we want to call at the location expected by the calling sequence. */ - void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr); + void (*set_function_addr) (struct regcache *regcache, CORE_ADDR func_addr) + = nullptr; }; -struct gdbarch_tdep +struct ia64_gdbarch_tdep : gdbarch_tdep { - CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int); - int (*pc_in_sigtramp) (CORE_ADDR); + CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int) + = nullptr; + int (*pc_in_sigtramp) (CORE_ADDR) = nullptr; /* Return the total size of THIS_FRAME's register frame. CFM is THIS_FRAME's cfm register value. Normally, the size of the register frame is always obtained by extracting the lowest 7 bits ("cfm & 0x7f"). */ - int (*size_of_register_frame) (struct frame_info *this_frame, ULONGEST cfm); + int (*size_of_register_frame) (struct frame_info *this_frame, ULONGEST cfm) + = nullptr; /* Determine the function address FADDR belongs to a shared library. If it does, then return the associated global pointer. If no shared @@ -245,10 +250,10 @@ struct gdbarch_tdep This pointer may be NULL. */ CORE_ADDR (*find_global_pointer_from_solib) (struct gdbarch *gdbarch, - CORE_ADDR faddr); + CORE_ADDR faddr) = nullptr; /* ISA-specific data types. */ - struct type *ia64_ext_type; + struct type *ia64_ext_type = nullptr; struct ia64_infcall_ops infcall_ops; }; diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 9c5dda3..3f91c05 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -42,7 +42,7 @@ #define LM32_REG2(insn) ((insn >> 11) & 0x1f) #define LM32_IMM16(insn) ((((long)insn & 0xffff) << 16) >> 16) -struct gdbarch_tdep +struct lm32_gdbarch_tdep : gdbarch_tdep { /* gdbarch target dependent data here. Currently unused for LM32. */ }; @@ -491,7 +491,6 @@ static struct gdbarch * lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -499,7 +498,7 @@ lm32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + lm32_gdbarch_tdep *tdep = new lm32_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Type sizes. */ 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. */ diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index 48cc42c..a9906ff 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -865,7 +865,6 @@ static struct gdbarch * m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -873,7 +872,7 @@ m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + m32r_gdbarch_tdep *tdep = new m32r_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); set_gdbarch_wchar_bit (gdbarch, 16); diff --git a/gdb/m32r-tdep.h b/gdb/m32r-tdep.h index ba6bad9..22c333c 100644 --- a/gdb/m32r-tdep.h +++ b/gdb/m32r-tdep.h @@ -20,7 +20,9 @@ #ifndef M32R_TDEP_H #define M32R_TDEP_H -struct gdbarch_tdep +#include "gdbarch.h" + +struct m32r_gdbarch_tdep : gdbarch_tdep { /* gdbarch target dependent data here. Currently unused for M32R. */ }; diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c index bbf7e5d..6d41fe8 100644 --- a/gdb/m68hc11-tdep.c +++ b/gdb/m68hc11-tdep.c @@ -123,27 +123,38 @@ enum insn_return_kind { #define M68HC12_HARD_PC_REGNUM (SOFT_D32_REGNUM+1) struct insn_sequence; -struct gdbarch_tdep +struct m68gc11_gdbarch_tdep : gdbarch_tdep { /* Stack pointer correction value. For 68hc11, the stack pointer points to the next push location. An offset of 1 must be applied to obtain the address where the last value is saved. For 68hc12, the stack pointer points to the last value pushed. No offset is necessary. */ - int stack_correction; + int stack_correction = 0; /* Description of instructions in the prologue. */ - struct insn_sequence *prologue; + struct insn_sequence *prologue = nullptr; /* True if the page memory bank register is available and must be used. */ - int use_page_register; + int use_page_register = 0; /* ELF flags for ABI. */ - int elf_flags; + int elf_flags = 0; }; -#define STACK_CORRECTION(gdbarch) (gdbarch_tdep (gdbarch)->stack_correction) -#define USE_PAGE_REGISTER(gdbarch) (gdbarch_tdep (gdbarch)->use_page_register) +static int +stack_correction (gdbarch *arch) +{ + m68gc11_gdbarch_tdep *tdep = (m68gc11_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->stack_correction; +} + +static int +use_page_register (gdbarch *arch) +{ + m68gc11_gdbarch_tdep *tdep = (m68gc11_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->stack_correction; +} struct m68hc11_unwind_cache { @@ -371,13 +382,15 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch, static const char * m68hc11_register_name (struct gdbarch *gdbarch, int reg_nr) { - if (reg_nr == M68HC12_HARD_PC_REGNUM && USE_PAGE_REGISTER (gdbarch)) + if (reg_nr == M68HC12_HARD_PC_REGNUM && use_page_register (gdbarch)) return "pc"; - if (reg_nr == HARD_PC_REGNUM && USE_PAGE_REGISTER (gdbarch)) + + if (reg_nr == HARD_PC_REGNUM && use_page_register (gdbarch)) return "ppc"; if (reg_nr < 0) return NULL; + if (reg_nr >= M68HC11_ALL_REGS) return NULL; @@ -387,6 +400,7 @@ m68hc11_register_name (struct gdbarch *gdbarch, int reg_nr) does not exist. */ if (reg_nr > M68HC11_LAST_HARD_REG && soft_regs[reg_nr].name == 0) return NULL; + return m68hc11_register_names[reg_nr]; } @@ -627,7 +641,8 @@ m68hc11_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, return pc; } - seq_table = gdbarch_tdep (gdbarch)->prologue; + m68gc11_gdbarch_tdep *tdep = (m68gc11_gdbarch_tdep *) gdbarch_tdep (gdbarch); + seq_table = tdep->prologue; /* The 68hc11 stack is as follows: @@ -807,7 +822,7 @@ m68hc11_frame_unwind_cache (struct frame_info *this_frame, info->saved_regs[HARD_PC_REGNUM].set_addr (info->sp_offset); this_base = get_frame_register_unsigned (this_frame, HARD_SP_REGNUM); prev_sp = this_base + info->sp_offset + 2; - this_base += STACK_CORRECTION (gdbarch); + this_base += stack_correction (gdbarch); } else { @@ -815,7 +830,7 @@ m68hc11_frame_unwind_cache (struct frame_info *this_frame, to before the first saved register giving the SP. */ prev_sp = this_base + info->size + 2; - this_base += STACK_CORRECTION (gdbarch); + this_base += stack_correction (gdbarch); if (soft_regs[SOFT_FP_REGNUM].name) info->saved_regs[SOFT_FP_REGNUM].set_addr (info->size - 2); } @@ -898,7 +913,7 @@ m68hc11_frame_prev_register (struct frame_info *this_frame, /* Take into account the 68HC12 specific call (PC + page). */ if (regnum == HARD_PC_REGNUM && info->return_kind == RETURN_RTC - && USE_PAGE_REGISTER (get_frame_arch (this_frame))) + && use_page_register (get_frame_arch (this_frame))) { CORE_ADDR pc = value_as_long (value); if (pc >= 0x08000 && pc < 0x0c000) @@ -1003,7 +1018,10 @@ m68hc11_print_register (struct gdbarch *gdbarch, struct ui_file *file, } else { - if (regno == HARD_PC_REGNUM && gdbarch_tdep (gdbarch)->use_page_register) + m68gc11_gdbarch_tdep *tdep + = (m68gc11_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (regno == HARD_PC_REGNUM && tdep->use_page_register) { ULONGEST page; @@ -1106,7 +1124,9 @@ m68hc11_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, fprintf_filtered (file, " Y="); m68hc11_print_register (gdbarch, file, frame, HARD_Y_REGNUM); - if (gdbarch_tdep (gdbarch)->use_page_register) + m68gc11_gdbarch_tdep *tdep = (m68gc11_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->use_page_register) { fprintf_filtered (file, "\nPage="); m68hc11_print_register (gdbarch, file, frame, HARD_PAGE_REGNUM); @@ -1194,7 +1214,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function, write_memory (sp, buf, 2); /* Finally, update the stack pointer... */ - sp -= STACK_CORRECTION (gdbarch); + sp -= stack_correction (gdbarch); regcache_cooked_write_unsigned (regcache, HARD_SP_REGNUM, sp); /* ...and fake a frame pointer. */ @@ -1386,7 +1406,6 @@ m68hc11_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int elf_flags; soft_reg_initialized = 0; @@ -1403,14 +1422,17 @@ m68hc11_gdbarch_init (struct gdbarch_info info, arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags) + m68gc11_gdbarch_tdep *tdep + = (m68gc11_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->elf_flags != elf_flags) continue; return arches->gdbarch; } /* Need a new architecture. Fill in a target specific vector. */ - tdep = XCNEW (struct gdbarch_tdep); + m68gc11_gdbarch_tdep *tdep = new m68gc11_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; diff --git a/gdb/m68k-bsd-tdep.c b/gdb/m68k-bsd-tdep.c index 593708f..27fbb84 100644 --- a/gdb/m68k-bsd-tdep.c +++ b/gdb/m68k-bsd-tdep.c @@ -133,7 +133,7 @@ m68kbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, static void m68kbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->jb_pc = 5; tdep->jb_elt_size = 4; diff --git a/gdb/m68k-linux-tdep.c b/gdb/m68k-linux-tdep.c index ad4d75a..6704d83 100644 --- a/gdb/m68k-linux-tdep.c +++ b/gdb/m68k-linux-tdep.c @@ -384,7 +384,7 @@ m68k_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, static void m68k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 75fa189..4ae27e6 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -70,7 +70,7 @@ typedef BP_MANIPULATION (m68k_break_insn) m68k_breakpoint; static struct type * m68k_ps_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->m68k_ps_type) { @@ -99,7 +99,7 @@ m68k_ps_type (struct gdbarch *gdbarch) static struct type * m68881_ext_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->m68881_ext_type) tdep->m68881_ext_type @@ -120,7 +120,7 @@ m68881_ext_type (struct gdbarch *gdbarch) static struct type * m68k_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->fpregs_present) { @@ -171,12 +171,14 @@ static const char * const m68k_register_names[] = { static const char * m68k_register_name (struct gdbarch *gdbarch, int regnum) { + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names)) internal_error (__FILE__, __LINE__, _("m68k_register_name: illegal register number %d"), regnum); else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM - && gdbarch_tdep (gdbarch)->fpregs_present == 0) + && tdep->fpregs_present == 0) return ""; else return m68k_register_names[regnum]; @@ -189,7 +191,9 @@ static int m68k_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type) { - if (!gdbarch_tdep (gdbarch)->fpregs_present) + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (!tdep->fpregs_present) return 0; return (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FP0_REGNUM + 7 /* We only support floating-point values. */ @@ -296,7 +300,7 @@ m68k_extract_return_value (struct type *type, struct regcache *regcache, if (type->code () == TYPE_CODE_PTR && len == 4) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); regcache->raw_read (tdep->pointer_result_regnum, valbuf); } else if (len <= 4) @@ -321,7 +325,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache, { gdb_byte buf[M68K_MAX_REGISTER_SIZE]; struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->float_return && type->code () == TYPE_CODE_FLT) { @@ -344,7 +348,7 @@ m68k_store_return_value (struct type *type, struct regcache *regcache, if (type->code () == TYPE_CODE_PTR && len == 4) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); regcache->raw_write (tdep->pointer_result_regnum, valbuf); /* gdb historically also set D0 in the SVR4 case. */ if (tdep->pointer_result_regnum != M68K_D0_REGNUM) @@ -367,7 +371,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->float_return && type->code () == TYPE_CODE_FLT) { @@ -387,7 +391,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, static int m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum type_code code = type->code (); int len = TYPE_LENGTH (type); @@ -465,6 +469,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, gdb_byte *readbuf, const gdb_byte *writebuf) { enum type_code code = type->code (); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Aggregates with a single member are always returned like their sole element. */ @@ -480,7 +485,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, || code == TYPE_CODE_COMPLEX || code == TYPE_CODE_ARRAY) && !m68k_reg_struct_return_p (gdbarch, type)) /* GCC may return a `long double' in memory too. */ - || (!gdbarch_tdep (gdbarch)->float_return + || (!tdep->float_return && code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) { @@ -500,7 +505,6 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, if (readbuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ULONGEST addr; regcache_raw_read_unsigned (regcache, tdep->pointer_result_regnum, @@ -537,7 +541,7 @@ m68k_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); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte buf[4]; int i; @@ -592,13 +596,15 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, static int m68k_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int num) { + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (num < 8) /* d0..7 */ return (num - 0) + M68K_D0_REGNUM; else if (num < 16) /* a0..7 */ return (num - 8) + M68K_A0_REGNUM; - else if (num < 24 && gdbarch_tdep (gdbarch)->fpregs_present) + else if (num < 24 && tdep->fpregs_present) /* fp0..7 */ return (num - 16) + M68K_FP0_REGNUM; else if (num == 25) @@ -760,6 +766,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc, struct m68k_frame_cache *cache) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (cache->locals >= 0) { @@ -772,7 +779,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc, { op = read_memory_unsigned_integer (pc, 2, byte_order); if (op == P_FMOVEMX_SP - && gdbarch_tdep (gdbarch)->fpregs_present) + && tdep->fpregs_present) { /* fmovem.x REGS,-(%sp) */ op = read_memory_unsigned_integer (pc + 2, 2, byte_order); @@ -1051,7 +1058,7 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) gdb_byte *buf; CORE_ADDR sp, jb_addr; struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); if (tdep->jb_pc < 0) @@ -1097,7 +1104,7 @@ m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch, void m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* SVR4 uses a different calling convention. */ set_gdbarch_return_value (gdbarch, m68k_svr4_return_value); @@ -1115,7 +1122,7 @@ m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) static void m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); m68k_svr4_init_abi (info, gdbarch); tdep->pointer_result_regnum = M68K_D0_REGNUM; @@ -1130,7 +1137,6 @@ m68k_embedded_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) static struct gdbarch * m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep = NULL; struct gdbarch *gdbarch; struct gdbarch_list *best_arch; tdesc_arch_data_up tdesc_data; @@ -1230,13 +1236,16 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) best_arch != NULL; best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) { - if (flavour != gdbarch_tdep (best_arch->gdbarch)->flavour) + m68k_gdbarch_tdep *tdep + = (m68k_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch); + + if (flavour != tdep->flavour) continue; - if (has_fp != gdbarch_tdep (best_arch->gdbarch)->fpregs_present) + if (has_fp != tdep->fpregs_present) continue; - if (float_return != gdbarch_tdep (best_arch->gdbarch)->float_return) + if (float_return != tdep->float_return) continue; break; @@ -1245,7 +1254,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (best_arch != NULL) return best_arch->gdbarch; - tdep = XCNEW (struct gdbarch_tdep); + m68k_gdbarch_tdep *tdep = new m68k_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->fpregs_present = has_fp; tdep->float_return = float_return; @@ -1330,7 +1339,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void m68k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + m68k_gdbarch_tdep *tdep = (m68k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep == NULL) return; diff --git a/gdb/m68k-tdep.h b/gdb/m68k-tdep.h index 16384d1..c88e7f2 100644 --- a/gdb/m68k-tdep.h +++ b/gdb/m68k-tdep.h @@ -67,38 +67,38 @@ enum m68k_flavour /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct m68k_gdbarch_tdep : gdbarch_tdep { /* Offset to PC value in the jump buffer. If this is negative, longjmp support will be disabled. */ - int jb_pc; + int jb_pc = 0; /* The size of each entry in the jump buffer. */ - size_t jb_elt_size; + size_t jb_elt_size = 0; /* Register in which the address to store a structure value is passed to a function. */ - int struct_value_regnum; + int struct_value_regnum = 0; /* Register in which a pointer value is returned. In the SVR4 ABI, this is %a0, but in GCC's "embedded" ABI, this is %d0. */ - int pointer_result_regnum; + int pointer_result_regnum = 0; /* Convention for returning structures. */ - enum struct_return struct_return; + enum struct_return struct_return {}; /* Convention for returning floats. zero in int regs, non-zero in float. */ - int float_return; + int float_return = 0; /* The particular flavour of m68k. */ - enum m68k_flavour flavour; + enum m68k_flavour flavour {}; /* Flag set if the floating point registers are present, or assumed to be present. */ - int fpregs_present; + int fpregs_present = 0; /* ISA-specific data types. */ - struct type *m68k_ps_type; - struct type *m68881_ext_type; + struct type *m68k_ps_type = nullptr; + struct type *m68881_ext_type = nullptr; }; /* Initialize a SVR4 architecture variant. */ diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index d48e1f1..6d1f04a 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -116,7 +116,7 @@ options are present on the current processor. */ -struct gdbarch_tdep +struct mep_gdbarch_tdep : gdbarch_tdep { /* A CGEN cpu descriptor for this BFD architecture and machine. @@ -124,7 +124,7 @@ struct gdbarch_tdep MeP libopcodes machinery actually puts off module-specific customization until the last minute. So this contains information about all supported me_modules. */ - CGEN_CPU_DESC cpu_desc; + CGEN_CPU_DESC cpu_desc = nullptr; /* The me_module index from the ELF file we used to select this architecture, or CONFIG_NONE if there was none. @@ -140,7 +140,7 @@ struct gdbarch_tdep create a separate instance of the gdbarch structure for each me_module value mep_gdbarch_init sees, and store the me_module value from the ELF file here. */ - CONFIG_ATTR me_module; + CONFIG_ATTR me_module {}; }; @@ -259,7 +259,9 @@ me_module_register_set (CONFIG_ATTR me_module, mask contains any of the me_module's coprocessor ISAs, specifically excluding the generic coprocessor register sets. */ - CGEN_CPU_DESC desc = gdbarch_tdep (target_gdbarch ())->cpu_desc; + mep_gdbarch_tdep *tdep + = (mep_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); + CGEN_CPU_DESC desc = tdep->cpu_desc; const CGEN_HW_ENTRY *hw; if (me_module == CONFIG_NONE) @@ -852,7 +854,11 @@ current_me_module (void) return (CONFIG_ATTR) regval; } else - return gdbarch_tdep (target_gdbarch ())->me_module; + { + mep_gdbarch_tdep *tdep + = (mep_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); + return tdep->me_module; + } } @@ -2326,7 +2332,6 @@ static struct gdbarch * mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* Which me_module are we building a gdbarch object for? */ CONFIG_ATTR me_module; @@ -2384,10 +2389,15 @@ mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) for (arches = gdbarch_list_lookup_by_info (arches, &info); arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) - if (gdbarch_tdep (arches->gdbarch)->me_module == me_module) - return arches->gdbarch; + { + mep_gdbarch_tdep *tdep + = (mep_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->me_module == me_module) + return arches->gdbarch; + } - tdep = XCNEW (struct gdbarch_tdep); + mep_gdbarch_tdep *tdep = new mep_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* Get a CGEN CPU descriptor for this architecture. */ diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c index 0c3316d..5309da5 100644 --- a/gdb/microblaze-tdep.c +++ b/gdb/microblaze-tdep.c @@ -650,7 +650,6 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch) static struct gdbarch * microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; @@ -697,7 +696,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + microblaze_gdbarch_tdep *tdep = new microblaze_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); set_gdbarch_long_double_bit (gdbarch, 128); diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h index 08af0d1..3143e92 100644 --- a/gdb/microblaze-tdep.h +++ b/gdb/microblaze-tdep.h @@ -22,7 +22,7 @@ /* Microblaze architecture-specific information. */ -struct gdbarch_tdep +struct microblaze_gdbarch_tdep : gdbarch_tdep { }; diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index ce287f6..9eac3d7 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -1317,7 +1317,7 @@ mips_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread) { struct regcache *regcache = get_thread_regcache (thread); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int regsize = register_size (gdbarch, MIPS_V0_REGNUM); /* The content of a register */ @@ -1527,7 +1527,7 @@ static void mips_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum mips_abi abi = mips_abi (gdbarch); struct tdesc_arch_data *tdesc_data = info.tdesc_data; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 89f689e..603c5d2 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -227,7 +227,8 @@ static const char mips_disassembler_options_n64[] = "gpr-names=64"; const struct mips_regnum * mips_regnum (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->regnum; + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->regnum; } static int @@ -248,29 +249,47 @@ mips_float_register_p (struct gdbarch *gdbarch, int regnum) && rawnum < mips_regnum (gdbarch)->fp0 + 32); } -#define MIPS_EABI(gdbarch) (gdbarch_tdep (gdbarch)->mips_abi \ - == MIPS_ABI_EABI32 \ - || gdbarch_tdep (gdbarch)->mips_abi == MIPS_ABI_EABI64) +static bool +mips_eabi (gdbarch *arch) +{ + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (arch); + return (tdep->mips_abi == MIPS_ABI_EABI32 \ + || tdep->mips_abi == MIPS_ABI_EABI64); +} -#define MIPS_LAST_FP_ARG_REGNUM(gdbarch) \ - (gdbarch_tdep (gdbarch)->mips_last_fp_arg_regnum) +static int +mips_last_fp_arg_regnum (gdbarch *arch) +{ + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->mips_last_fp_arg_regnum; +} -#define MIPS_LAST_ARG_REGNUM(gdbarch) \ - (gdbarch_tdep (gdbarch)->mips_last_arg_regnum) +static int +mips_last_arg_regnum (gdbarch *arch) +{ + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->mips_last_arg_regnum; +} -#define MIPS_FPU_TYPE(gdbarch) (gdbarch_tdep (gdbarch)->mips_fpu_type) +static enum mips_fpu_type +mips_get_fpu_type (gdbarch *arch) +{ + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->mips_fpu_type; +} /* Return the MIPS ABI associated with GDBARCH. */ enum mips_abi mips_abi (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->mips_abi; + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->mips_abi; } int mips_isa_regsize (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* If we know how big the registers are, use that size. */ if (tdep->register_size_valid_p) @@ -316,7 +335,8 @@ mips_abi_regsize (struct gdbarch *gdbarch) static int is_mips16_isa (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->mips_isa == ISA_MIPS16; + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->mips_isa == ISA_MIPS16; } /* Return one iff compressed code is the microMIPS instruction set. */ @@ -324,7 +344,8 @@ is_mips16_isa (struct gdbarch *gdbarch) static int is_micromips_isa (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->mips_isa == ISA_MICROMIPS; + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->mips_isa == ISA_MICROMIPS; } /* Return one iff ADDR denotes compressed code. */ @@ -615,7 +636,7 @@ static const char * const mips_linux_reg_names[NUM_MIPS_PROCESSOR_REGS] = { static const char * mips_register_name (struct gdbarch *gdbarch, int regno) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* GPR names for all ABIs other than n32/n64. */ static const char *mips_gpr_names[] = { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", @@ -756,7 +777,9 @@ mips_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, else if (register_size (gdbarch, rawnum) > register_size (gdbarch, cookednum)) { - if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p) + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->mips64_transfers_32bit_regs_p) return regcache->raw_read_part (rawnum, 0, 4, buf); else { @@ -787,7 +810,9 @@ mips_pseudo_register_write (struct gdbarch *gdbarch, else if (register_size (gdbarch, rawnum) > register_size (gdbarch, cookednum)) { - if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p) + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->mips64_transfers_32bit_regs_p) regcache->raw_write_part (rawnum, 0, 4, buf); else { @@ -829,7 +854,10 @@ mips_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, if (register_size (gdbarch, rawnum) > register_size (gdbarch, reg)) { - if (!gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (!tdep->mips64_transfers_32bit_regs_p || gdbarch_byte_order (gdbarch) != BFD_ENDIAN_BIG) { ax_const_l (ax, 32); @@ -1031,6 +1059,7 @@ mips_register_type (struct gdbarch *gdbarch, int regnum) else { int rawnum = regnum - gdbarch_num_regs (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* The cooked or ABI registers. These are sized according to the ABI (with a few complications). */ @@ -1043,7 +1072,7 @@ mips_register_type (struct gdbarch *gdbarch, int regnum) /* The pseudo/cooked view of the embedded registers is always 32-bit. The raw view is handled below. */ return builtin_type (gdbarch)->builtin_int32; - else if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p) + else if (tdep->mips64_transfers_32bit_regs_p) /* The target, while possibly using a 64-bit register buffer, is only transfering 32-bits of each integer register. Reflect this in the cooked/pseudo (ABI) register value. */ @@ -1132,7 +1161,7 @@ mips_pseudo_register_type (struct gdbarch *gdbarch, int regnum) static enum auto_boolean mask_address_var = AUTO_BOOLEAN_AUTO; static int -mips_mask_address_p (struct gdbarch_tdep *tdep) +mips_mask_address_p (mips_gdbarch_tdep *tdep) { switch (mask_address_var) { @@ -1154,7 +1183,8 @@ static void show_mask_address (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) { - struct gdbarch_tdep *tdep = gdbarch_tdep (target_gdbarch ()); + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (target_gdbarch ()); deprecated_show_value_hack (file, from_tty, c, value); switch (mask_address_var) @@ -1698,9 +1728,9 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR pc) break; case 12: /* SYSCALL */ { - struct gdbarch_tdep *tdep; + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); - tdep = gdbarch_tdep (gdbarch); if (tdep->syscall_next_pc != NULL) pc = tdep->syscall_next_pc (get_current_frame ()); else @@ -1909,9 +1939,9 @@ micromips_next_pc (struct regcache *regcache, CORE_ADDR pc) break; case 0x22d: /* SYSCALL: 000000 1000101101 111100 */ { - struct gdbarch_tdep *tdep; + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); - tdep = gdbarch_tdep (gdbarch); if (tdep->syscall_next_pc != NULL) pc = tdep->syscall_next_pc (get_current_frame ()); } @@ -3870,7 +3900,7 @@ mips_stub_frame_base_sniffer (struct frame_info *this_frame) static CORE_ADDR mips_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (mips_mask_address_p (tdep) && (((ULONGEST) addr) >> 32 == 0xffffffffUL)) /* This hack is a work-around for existing boards using PMON, the @@ -4405,13 +4435,13 @@ fp_register_arg_p (struct gdbarch *gdbarch, enum type_code typecode, struct type *arg_type) { return ((typecode == TYPE_CODE_FLT - || (MIPS_EABI (gdbarch) + || (mips_eabi (gdbarch) && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) && arg_type->num_fields () == 1 && check_typedef (arg_type->field (0).type ())->code () == TYPE_CODE_FLT)) - && MIPS_FPU_TYPE(gdbarch) != MIPS_FPU_NONE); + && mips_get_fpu_type (gdbarch) != MIPS_FPU_NONE); } /* On o32, argument passing in GPRs depends on the alignment of the type being @@ -4611,7 +4641,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, point value into an FP register instead of pushing it onto the stack. */ if (fp_register_arg_p (gdbarch, typecode, arg_type) - && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch)) + && float_argreg <= mips_last_fp_arg_regnum (gdbarch)) { /* EABI32 will pass doubles in consecutive registers, even on 64-bit cores. At one time, we used to check the size of @@ -4678,7 +4708,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, partial_len); /* Write this portion of the argument to the stack. */ - if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch) + if (argreg > mips_last_arg_regnum (gdbarch) || odd_sized_struct || fp_register_arg_p (gdbarch, typecode, arg_type)) { @@ -4729,7 +4759,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, arguments will not. */ /* Write this portion of the argument to a general purpose register. */ - if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch) + if (argreg <= mips_last_arg_regnum (gdbarch) && !fp_register_arg_p (gdbarch, typecode, arg_type)) { LONGEST regval = @@ -4773,7 +4803,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); int fp_return_type = 0; int offset, regnum, xfer; @@ -4845,7 +4875,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type, if (arg_type->code () != TYPE_CODE_STRUCT) return 0; - if (MIPS_FPU_TYPE (gdbarch) != MIPS_FPU_DOUBLE) + if (mips_get_fpu_type (gdbarch) != MIPS_FPU_DOUBLE) return 0; if (TYPE_LENGTH (arg_type) < offset + MIPS64_REGSIZE) @@ -4973,7 +5003,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } if (fp_register_arg_p (gdbarch, typecode, arg_type) - && argreg <= MIPS_LAST_ARG_REGNUM (gdbarch)) + && argreg <= mips_last_arg_regnum (gdbarch)) { /* This is a floating point value that fits entirely in a single register or a pair of registers. */ @@ -5033,10 +5063,10 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, partial_len); if (fp_register_arg_p (gdbarch, typecode, arg_type)) - gdb_assert (argreg > MIPS_LAST_ARG_REGNUM (gdbarch)); + gdb_assert (argreg > mips_last_arg_regnum (gdbarch)); /* Write this portion of the argument to the stack. */ - if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch)) + if (argreg > mips_last_arg_regnum (gdbarch)) { /* Should shorter than int integer values be promoted to int before being stored? */ @@ -5079,7 +5109,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, structs may go thru BOTH paths. */ /* Write this portion of the argument to a general purpose register. */ - if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch)) + if (argreg <= mips_last_arg_regnum (gdbarch)) { LONGEST regval; @@ -5164,7 +5194,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* From MIPSpro N32 ABI Handbook, Document Number: 007-2816-004 @@ -5451,7 +5481,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, registers are normally skipped. */ if (fp_register_arg_p (gdbarch, typecode, arg_type) - && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch)) + && float_argreg <= mips_last_fp_arg_regnum (gdbarch)) { if (register_size (gdbarch, float_argreg) < 8 && len == 8) { @@ -5541,7 +5571,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, partial_len); /* Write this portion of the argument to the stack. */ - if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch) + if (argreg > mips_last_arg_regnum (gdbarch) || odd_sized_struct) { /* Should shorter than int integer values be @@ -5577,7 +5607,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, structs may go thru BOTH paths. */ /* Write this portion of the argument to a general purpose register. */ - if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch)) + if (argreg <= mips_last_arg_regnum (gdbarch)) { LONGEST regval = extract_signed_integer (val, partial_len, byte_order); @@ -5625,7 +5655,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Prevent subsequent floating point arguments from being passed in floating point registers. */ - float_argreg = MIPS_LAST_FP_ARG_REGNUM (gdbarch) + 1; + float_argreg = mips_last_fp_arg_regnum (gdbarch) + 1; } len -= partial_len; @@ -5659,7 +5689,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, { CORE_ADDR func_addr = function ? find_function_addr (function, NULL) : 0; int mips16 = mips_pc_is_mips16 (gdbarch, func_addr); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum mips_fval_reg fval_reg; fval_reg = readbuf ? mips16 ? mips_fval_gpr : mips_fval_fpr : mips_fval_both; @@ -5960,7 +5990,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, functions because those registers are normally skipped. */ if (fp_register_arg_p (gdbarch, typecode, arg_type) - && float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch)) + && float_argreg <= mips_last_fp_arg_regnum (gdbarch)) { LONGEST regval = extract_unsigned_integer (val, len, byte_order); if (mips_debug) @@ -5995,7 +6025,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, partial_len); /* Write this portion of the argument to the stack. */ - if (argreg > MIPS_LAST_ARG_REGNUM (gdbarch) + if (argreg > mips_last_arg_regnum (gdbarch) || odd_sized_struct) { /* Should shorter than int integer values be @@ -6039,7 +6069,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, structs may go thru BOTH paths. */ /* Write this portion of the argument to a general purpose register. */ - if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch)) + if (argreg <= mips_last_arg_regnum (gdbarch)) { LONGEST regval = extract_signed_integer (val, partial_len, byte_order); @@ -6071,7 +6101,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Prevent subsequent floating point arguments from being passed in floating point registers. */ - float_argreg = MIPS_LAST_FP_ARG_REGNUM (gdbarch) + 1; + float_argreg = mips_last_fp_arg_regnum (gdbarch) + 1; } len -= partial_len; @@ -6403,7 +6433,7 @@ mips_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, const char *args) { int fcsr = mips_regnum (gdbarch)->fp_control_status; - enum mips_fpu_type type = MIPS_FPU_TYPE (gdbarch); + enum mips_fpu_type type = mips_get_fpu_type (gdbarch); ULONGEST fcs = 0; int i; @@ -6891,7 +6921,7 @@ show_mipsfpu_command (const char *args, int from_tty) return; } - switch (MIPS_FPU_TYPE (target_gdbarch ())) + switch (mips_get_fpu_type (target_gdbarch ())) { case MIPS_FPU_SINGLE: fpu = "single-precision"; @@ -8038,7 +8068,6 @@ static struct gdbarch * mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int elf_flags; enum mips_abi mips_abi, found_abi, wanted_abi; int i, num_regs; @@ -8055,7 +8084,11 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour) elf_flags = elf_elfheader (info.abfd)->e_flags; else if (arches != NULL) - elf_flags = gdbarch_tdep (arches->gdbarch)->elf_flags; + { + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + elf_flags = tdep->elf_flags; + } else elf_flags = 0; if (gdbarch_debug) @@ -8092,7 +8125,11 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* If we have no useful BFD information, use the ABI from the last MIPS architecture (if there is one). */ if (found_abi == MIPS_ABI_UNKNOWN && info.abfd == NULL && arches != NULL) - found_abi = gdbarch_tdep (arches->gdbarch)->found_abi; + { + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + found_abi = tdep->found_abi; + } /* Try the architecture for any hint of the correct ABI. */ if (found_abi == MIPS_ABI_UNKNOWN @@ -8223,7 +8260,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) break; } else if (arches != NULL) - fpu_type = MIPS_FPU_TYPE (arches->gdbarch); + fpu_type = mips_get_fpu_type (arches->gdbarch); else fpu_type = MIPS_FPU_DOUBLE; if (gdbarch_debug) @@ -8406,28 +8443,31 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { + mips_gdbarch_tdep *tdep + = (mips_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + /* MIPS needs to be pedantic about which ABI and the compressed ISA variation the object is using. */ - if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags) + if (tdep->elf_flags != elf_flags) continue; - if (gdbarch_tdep (arches->gdbarch)->mips_abi != mips_abi) + if (tdep->mips_abi != mips_abi) continue; - if (gdbarch_tdep (arches->gdbarch)->mips_isa != mips_isa) + if (tdep->mips_isa != mips_isa) continue; /* Need to be pedantic about which register virtual size is used. */ - if (gdbarch_tdep (arches->gdbarch)->mips64_transfers_32bit_regs_p + if (tdep->mips64_transfers_32bit_regs_p != mips64_transfers_32bit_regs_p) continue; /* Be pedantic about which FPU is selected. */ - if (MIPS_FPU_TYPE (arches->gdbarch) != fpu_type) + if (mips_get_fpu_type (arches->gdbarch) != fpu_type) continue; return arches->gdbarch; } /* Need a new architecture. Fill in a target specific vector. */ - tdep = XCNEW (struct gdbarch_tdep); + mips_gdbarch_tdep *tdep = new mips_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; tdep->mips64_transfers_32bit_regs_p = mips64_transfers_32bit_regs_p; @@ -8862,7 +8902,7 @@ mips_fpu_type_str (enum mips_fpu_type fpu_type) static void mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mips_gdbarch_tdep *tdep = (mips_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep != NULL) { int ef_mips_arch; @@ -8911,11 +8951,11 @@ mips_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) MIPS_DEFAULT_FPU_TYPE, mips_fpu_type_str (MIPS_DEFAULT_FPU_TYPE)); fprintf_unfiltered (file, "mips_dump_tdep: MIPS_EABI = %d\n", - MIPS_EABI (gdbarch)); + mips_eabi (gdbarch)); fprintf_unfiltered (file, "mips_dump_tdep: MIPS_FPU_TYPE = %d (%s)\n", - MIPS_FPU_TYPE (gdbarch), - mips_fpu_type_str (MIPS_FPU_TYPE (gdbarch))); + mips_get_fpu_type (gdbarch), + mips_fpu_type_str (mips_get_fpu_type (gdbarch))); } void _initialize_mips_tdep (); diff --git a/gdb/mips-tdep.h b/gdb/mips-tdep.h index e7f6837..b899cfd 100644 --- a/gdb/mips-tdep.h +++ b/gdb/mips-tdep.h @@ -83,39 +83,39 @@ enum mips_fpu_type }; /* MIPS specific per-architecture information. */ -struct gdbarch_tdep +struct mips_gdbarch_tdep : gdbarch_tdep { /* from the elf header */ - int elf_flags; + int elf_flags = 0; /* mips options */ - enum mips_abi mips_abi; - enum mips_abi found_abi; - enum mips_isa mips_isa; - enum mips_fpu_type mips_fpu_type; - int mips_last_arg_regnum; - int mips_last_fp_arg_regnum; - int default_mask_address_p; + enum mips_abi mips_abi {}; + enum mips_abi found_abi {}; + enum mips_isa mips_isa {}; + enum mips_fpu_type mips_fpu_type {}; + int mips_last_arg_regnum = 0; + int mips_last_fp_arg_regnum = 0; + int default_mask_address_p = 0; /* Is the target using 64-bit raw integer registers but only storing a left-aligned 32-bit value in each? */ - int mips64_transfers_32bit_regs_p; + int mips64_transfers_32bit_regs_p = 0; /* Indexes for various registers. IRIX and embedded have different values. This contains the "public" fields. Don't add any that do not need to be public. */ - const struct mips_regnum *regnum; + const struct mips_regnum *regnum = nullptr; /* Register names table for the current register set. */ - const char * const *mips_processor_reg_names; + const char * const *mips_processor_reg_names = nullptr; /* The size of register data available from the target, if known. This doesn't quite obsolete the manual mips64_transfers_32bit_regs_p, since that is documented to force left alignment even for big endian (very strange). */ - int register_size_valid_p; - int register_size; + int register_size_valid_p = 0; + int register_size = 0; /* Return the expected next PC if FRAME is stopped at a syscall instruction. */ - CORE_ADDR (*syscall_next_pc) (struct frame_info *frame); + CORE_ADDR (*syscall_next_pc) (struct frame_info *frame) = nullptr; }; /* Register numbers of various important registers. */ diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 7feab0b..5804efe 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -372,7 +372,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, int rn; pv_t regs[MN10300_MAX_NUM_REGS]; CORE_ADDR after_last_frame_setup_insn = start_pc; - int am33_mode = AM33_MODE (gdbarch); + int am33_mode = get_am33_mode (gdbarch); memset (result, 0, sizeof (*result)); result->gdbarch = gdbarch; @@ -1337,14 +1337,13 @@ mn10300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int num_regs; arches = gdbarch_list_lookup_by_info (arches, &info); if (arches != NULL) return arches->gdbarch; - tdep = XCNEW (struct gdbarch_tdep); + mn10300_gdbarch_tdep *tdep = new mn10300_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); switch (info.bfd_arch_info->mach) @@ -1413,7 +1412,7 @@ mn10300_gdbarch_init (struct gdbarch_info info, static void mn10300_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + mn10300_gdbarch_tdep *tdep = (mn10300_gdbarch_tdep *) gdbarch_tdep (gdbarch); fprintf_unfiltered (file, "mn10300_dump_tdep: am33_mode = %d\n", tdep->am33_mode); } diff --git a/gdb/mn10300-tdep.h b/gdb/mn10300-tdep.h index a351849..220e4d6 100644 --- a/gdb/mn10300-tdep.h +++ b/gdb/mn10300-tdep.h @@ -20,6 +20,8 @@ #ifndef MN10300_TDEP_H #define MN10300_TDEP_H +#include "gdbarch.h" + enum { E_D0_REGNUM = 0, E_D1_REGNUM = 1, @@ -74,11 +76,16 @@ enum frame_kind { }; /* mn10300 private data. */ -struct gdbarch_tdep +struct mn10300_gdbarch_tdep : gdbarch_tdep { int am33_mode; }; -#define AM33_MODE(gdbarch) (gdbarch_tdep (gdbarch)->am33_mode) +static inline int +get_am33_mode (gdbarch *arch) +{ + mn10300_gdbarch_tdep *tdep = (mn10300_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->am33_mode; +} #endif /* MN10300_TDEP_H */ diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index c48f9f7..459bfb8 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -1052,7 +1052,6 @@ static struct gdbarch * moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -1060,7 +1059,7 @@ moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + moxie_gdbarch_tdep *tdep = new moxie_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); set_gdbarch_wchar_bit (gdbarch, 32); diff --git a/gdb/moxie-tdep.h b/gdb/moxie-tdep.h index b3687ef..4e6bcd1 100644 --- a/gdb/moxie-tdep.h +++ b/gdb/moxie-tdep.h @@ -20,7 +20,7 @@ #ifndef MOXIE_TDEP_H #define MOXIE_TDEP_H -struct gdbarch_tdep +struct moxie_gdbarch_tdep : gdbarch_tdep { /* gdbarch target dependent data here. Currently unused for MOXIE. */ }; diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index c1b0c4c..f3c44b7 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -104,19 +104,19 @@ enum /* Architecture specific data. */ -struct gdbarch_tdep +struct msp430_gdbarch_tdep : gdbarch_tdep { /* The ELF header flags specify the multilib used. */ - int elf_flags; + int elf_flags = 0; /* One of MSP_ISA_MSP430 or MSP_ISA_MSP430X. */ - int isa; + int isa = 0; /* One of MSP_SMALL_CODE_MODEL or MSP_LARGE_CODE_MODEL. If, at some point, we support different data models too, we'll probably structure things so that we can combine values using logical "or". */ - int code_model; + int code_model = 0; }; /* This structure holds the results of a prologue analysis. */ @@ -340,7 +340,8 @@ msp430_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc, int rn; pv_t reg[MSP430_NUM_TOTAL_REGS]; CORE_ADDR after_last_frame_setup_insn = start_pc; - int code_model = gdbarch_tdep (gdbarch)->code_model; + msp430_gdbarch_tdep *tdep = (msp430_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int code_model = tdep->code_model; int sz; memset (result, 0, sizeof (*result)); @@ -568,7 +569,8 @@ msp430_return_value (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); LONGEST valtype_len = TYPE_LENGTH (valtype); - int code_model = gdbarch_tdep (gdbarch)->code_model; + msp430_gdbarch_tdep *tdep = (msp430_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int code_model = tdep->code_model; if (TYPE_LENGTH (valtype) > 8 || valtype->code () == TYPE_CODE_STRUCT @@ -648,7 +650,8 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int write_pass; int sp_off = 0; CORE_ADDR cfa; - int code_model = gdbarch_tdep (gdbarch)->code_model; + msp430_gdbarch_tdep *tdep = (msp430_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int code_model = tdep->code_model; struct type *func_type = value_type (function); @@ -766,8 +769,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Push the return address. */ { - int sz = (gdbarch_tdep (gdbarch)->code_model == MSP_SMALL_CODE_MODEL) - ? 2 : 4; + int sz = tdep->code_model == MSP_SMALL_CODE_MODEL ? 2 : 4; sp = sp - sz; write_memory_unsigned_integer (sp, sz, byte_order, bp_addr); } @@ -811,7 +813,8 @@ msp430_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) stub_name = bms.minsym->linkage_name (); - if (gdbarch_tdep (gdbarch)->code_model == MSP_SMALL_CODE_MODEL + msp430_gdbarch_tdep *tdep = (msp430_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->code_model == MSP_SMALL_CODE_MODEL && msp430_in_return_stub (gdbarch, pc, stub_name)) { CORE_ADDR sp = get_frame_register_unsigned (frame, MSP430_SP_REGNUM); @@ -830,7 +833,6 @@ static struct gdbarch * msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int elf_flags, isa, code_model; /* Extract the elf_flags if available. */ @@ -873,7 +875,8 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) struct gdbarch *ca = get_current_arch (); if (ca && gdbarch_bfd_arch_info (ca)->arch == bfd_arch_msp430) { - struct gdbarch_tdep *ca_tdep = gdbarch_tdep (ca); + msp430_gdbarch_tdep *ca_tdep + = (msp430_gdbarch_tdep *) gdbarch_tdep (ca); elf_flags = ca_tdep->elf_flags; isa = ca_tdep->isa; @@ -899,7 +902,8 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - struct gdbarch_tdep *candidate_tdep = gdbarch_tdep (arches->gdbarch); + msp430_gdbarch_tdep *candidate_tdep + = (msp430_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); if (candidate_tdep->elf_flags != elf_flags || candidate_tdep->isa != isa @@ -911,7 +915,7 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + msp430_gdbarch_tdep *tdep = new msp430_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; tdep->isa = isa; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 828853e..0360323 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -289,7 +289,7 @@ typedef BP_MANIPULATION (nds32_break_insn) nds32_breakpoint; static int nds32_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int num) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); const int FSR = 38; const int FDR = FSR + 32; @@ -440,7 +440,7 @@ nds32_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte reg_buf[8]; int offset, fdr_regnum; enum register_status status; @@ -479,7 +479,7 @@ nds32_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte reg_buf[8]; int offset, fdr_regnum; @@ -616,7 +616,7 @@ static CORE_ADDR nds32_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR limit_pc, struct nds32_frame_cache *cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); /* Current scanning status. */ int in_prologue_bb = 0; @@ -1177,7 +1177,7 @@ static int nds32_analyze_epilogue (struct gdbarch *gdbarch, CORE_ADDR pc, struct nds32_frame_cache *cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); CORE_ADDR limit_pc; uint32_t insn, insn_len; @@ -1228,7 +1228,7 @@ nds32_analyze_epilogue (struct gdbarch *gdbarch, CORE_ADDR pc, static int nds32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); int insn_type = INSN_NORMAL; int ret_found = 0; @@ -1432,7 +1432,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int i; ULONGEST regval; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct type *func_type = value_type (function); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); int abi_split = nds32_abi_split (tdep->elf_abi); @@ -1660,7 +1660,7 @@ nds32_extract_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, gdb_byte *valbuf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); int calling_use_fpr; int len; @@ -1750,7 +1750,7 @@ nds32_store_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, const gdb_byte *valbuf) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nds32_gdbarch_tdep *tdep = (nds32_gdbarch_tdep *) gdbarch_tdep (gdbarch); int abi_use_fpr = nds32_abi_use_fpr (tdep->elf_abi); int calling_use_fpr; int len; @@ -1955,7 +1955,6 @@ static struct gdbarch * nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; struct gdbarch_list *best_arch; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; @@ -1973,7 +1972,8 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) best_arch != NULL; best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) { - struct gdbarch_tdep *idep = gdbarch_tdep (best_arch->gdbarch); + nds32_gdbarch_tdep *idep + = (nds32_gdbarch_tdep *) gdbarch_tdep (best_arch->gdbarch); if (idep->elf_abi != elf_abi) continue; @@ -1995,7 +1995,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return NULL; /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + nds32_gdbarch_tdep *tdep = new nds32_gdbarch_tdep; tdep->fpu_freg = fpu_freg; tdep->use_pseudo_fsrs = use_pseudo_fsrs; tdep->fs0_regnum = -1; diff --git a/gdb/nds32-tdep.h b/gdb/nds32-tdep.h index 2422930..e065123 100644 --- a/gdb/nds32-tdep.h +++ b/gdb/nds32-tdep.h @@ -40,15 +40,15 @@ enum nds32_regnum NDS32_FD0_REGNUM = NDS32_NUM_REGS, }; -struct gdbarch_tdep +struct nds32_gdbarch_tdep : gdbarch_tdep { /* The guessed FPU configuration. */ - int fpu_freg; + int fpu_freg = 0; /* FSRs are defined as pseudo registers. */ - int use_pseudo_fsrs; + int use_pseudo_fsrs = 0; /* Cached regnum of the first FSR (FS0). */ - int fs0_regnum; + int fs0_regnum = 0; /* ELF ABI info. */ - int elf_abi; + int elf_abi = 0; }; #endif /* NDS32_TDEP_H */ diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c index bd86146..2e360ba 100644 --- a/gdb/nios2-linux-tdep.c +++ b/gdb/nios2-linux-tdep.c @@ -217,7 +217,7 @@ nios2_linux_is_kernel_helper (CORE_ADDR pc) static void nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nios2_gdbarch_tdep *tdep = (nios2_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/nios2-tdep.c b/gdb/nios2-tdep.c index be5544e..706b579 100644 --- a/gdb/nios2-tdep.c +++ b/gdb/nios2-tdep.c @@ -2098,7 +2098,7 @@ static CORE_ADDR nios2_get_next_pc (struct regcache *regcache, CORE_ADDR pc) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nios2_gdbarch_tdep *tdep = (nios2_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach; unsigned int insn; const struct nios2_opcode *op = nios2_fetch_insn (gdbarch, pc, &insn); @@ -2221,7 +2221,7 @@ static int nios2_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + nios2_gdbarch_tdep *tdep = (nios2_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR jb_addr = get_frame_register_unsigned (frame, NIOS2_R4_REGNUM); gdb_byte buf[4]; @@ -2275,7 +2275,6 @@ static struct gdbarch * nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int i; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; @@ -2313,7 +2312,7 @@ nios2_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + nios2_gdbarch_tdep *tdep = new nios2_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); /* longjmp support not enabled by default. */ diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h index f9e7349..96f1865 100644 --- a/gdb/nios2-tdep.h +++ b/gdb/nios2-tdep.h @@ -20,6 +20,8 @@ #ifndef NIOS2_TDEP_H #define NIOS2_TDEP_H +#include "gdbarch.h" + /* Nios II ISA specific encodings and macros. */ #include "opcode/nios2.h" @@ -67,19 +69,19 @@ #define NIOS2_CDX_OPCODE_SIZE 2 /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct nios2_gdbarch_tdep : gdbarch_tdep { /* Assumes FRAME is stopped at a syscall (trap) instruction; returns the expected next PC. */ CORE_ADDR (*syscall_next_pc) (struct frame_info *frame, - const struct nios2_opcode *op); + const struct nios2_opcode *op) = nullptr; /* Returns true if PC points to a kernel helper function. */ - bool (*is_kernel_helper) (CORE_ADDR pc); + bool (*is_kernel_helper) (CORE_ADDR pc) = nullptr; /* Offset to PC value in jump buffer. If this is negative, longjmp support will be disabled. */ - int jb_pc; + int jb_pc = 0; }; extern struct target_desc *tdesc_nios2_linux; diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 4c42e02..346ee97 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -62,11 +62,11 @@ show_or1k_debug (struct ui_file *file, int from_tty, /* The target-dependent structure for gdbarch. */ -struct gdbarch_tdep +struct or1k_gdbarch_tdep : gdbarch_tdep { - int bytes_per_word; - int bytes_per_address; - CGEN_CPU_DESC gdb_cgen_cpu_desc; + int bytes_per_word = 0; + int bytes_per_address = 0; + CGEN_CPU_DESC gdb_cgen_cpu_desc = nullptr; }; /* Support functions for the architecture definition. */ @@ -247,7 +247,8 @@ or1k_return_value (struct gdbarch *gdbarch, struct value *functype, enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum type_code rv_type = valtype->code (); unsigned int rv_size = TYPE_LENGTH (valtype); - int bpw = (gdbarch_tdep (gdbarch))->bytes_per_word; + or1k_gdbarch_tdep *tdep = (or1k_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int bpw = tdep->bytes_per_word; /* Deal with struct/union as addresses. If an array won't fit in a single register it is returned as address. Anything larger than 2 @@ -351,7 +352,7 @@ or1k_delay_slot_p (struct gdbarch *gdbarch, CORE_ADDR pc) { const CGEN_INSN *insn; CGEN_FIELDS tmp_fields; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + or1k_gdbarch_tdep *tdep = (or1k_gdbarch_tdep *) gdbarch_tdep (gdbarch); insn = cgen_lookup_insn (tdep->gdb_cgen_cpu_desc, NULL, @@ -633,8 +634,9 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int heap_offset = 0; CORE_ADDR heap_sp = sp - 128; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int bpa = (gdbarch_tdep (gdbarch))->bytes_per_address; - int bpw = (gdbarch_tdep (gdbarch))->bytes_per_word; + or1k_gdbarch_tdep *tdep = (or1k_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int bpa = tdep->bytes_per_address; + int bpw = tdep->bytes_per_word; struct type *func_type = value_type (function); /* Return address */ @@ -1140,7 +1142,6 @@ static struct gdbarch * or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; const struct bfd_arch_info *binfo; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; @@ -1155,7 +1156,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) actually know which target we are talking to, but put in some defaults for now. */ binfo = info.bfd_arch_info; - tdep = XCNEW (struct gdbarch_tdep); + or1k_gdbarch_tdep *tdep = new or1k_gdbarch_tdep; tdep->bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte; tdep->bytes_per_address = binfo->bits_per_address / binfo->bits_per_byte; gdbarch = gdbarch_alloc (&info, tdep); @@ -1283,7 +1284,7 @@ or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void or1k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + or1k_gdbarch_tdep *tdep = (or1k_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (NULL == tdep) return; /* Nothing to report */ diff --git a/gdb/ppc-fbsd-tdep.c b/gdb/ppc-fbsd-tdep.c index f41c8bb..87d2a69 100644 --- a/gdb/ppc-fbsd-tdep.c +++ b/gdb/ppc-fbsd-tdep.c @@ -126,7 +126,7 @@ ppcfbsd_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->wordsize == 4) cb (".reg", 148, 148, &ppc32_fbsd_gregset, NULL, cb_data); @@ -200,7 +200,7 @@ static struct trad_frame_cache * ppcfbsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct trad_frame_cache *cache; CORE_ADDR addr, base, func; gdb_byte buf[PPC_INSN_SIZE]; @@ -287,7 +287,7 @@ static CORE_ADDR ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, CORE_ADDR lm_addr, CORE_ADDR offset) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct regcache *regcache; int tp_offset, tp_regnum; @@ -319,7 +319,7 @@ ppcfbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid, static void ppcfbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index e2e1b1e..6df2411 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -332,7 +332,7 @@ ppc_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { unsigned int insnbuf[POWERPC32_PLT_CHECK_LEN]; struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR target = 0; int scan_limit, i; @@ -898,7 +898,7 @@ ppc_linux_vsxregset (void) const struct regset * ppc_linux_cgprregset (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->wordsize == 4) { @@ -938,7 +938,7 @@ ppc_linux_collect_core_cpgrregset (const struct regset *regset, int regnum, void *buf, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct regset *cgprregset = ppc_linux_cgprregset (gdbarch); @@ -985,7 +985,7 @@ ppc_linux_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int have_altivec = tdep->ppc_vr0_regnum != -1; int have_vsx = tdep->ppc_vsr0_upper_regnum != -1; int have_ppr = tdep->ppc_ppr_regnum != -1; @@ -1170,7 +1170,7 @@ ppc_linux_sigtramp_cache (struct frame_info *this_frame, CORE_ADDR fpregs; int i; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); base = get_frame_register_unsigned (this_frame, @@ -1341,7 +1341,7 @@ ppc_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread) { struct regcache *regcache = get_thread_regcache (thread); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); /* Make sure we're in a 32- or 64-bit machine */ @@ -1417,7 +1417,7 @@ static int ppc_linux_syscall_record (struct regcache *regcache) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST scnum; enum gdb_syscall syscall_gdb; int ret; @@ -1506,7 +1506,7 @@ ppc_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, const int SIGNAL_FRAMESIZE = 128; const int sizeof_rt_sigframe = 1440 * 2 + 8 * 2 + 4 * 6 + 8 + 8 + 128 + 512; ULONGEST sp; - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int i; for (i = 3; i <= 12; i++) @@ -2018,7 +2018,7 @@ static void ppc_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct tdesc_arch_data *tdesc_data = info.tdesc_data; static const char *const stap_integer_prefixes[] = { "i", NULL }; static const char *const stap_register_indirection_prefixes[] = { "(", diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c index 31f1199..97912eb 100644 --- a/gdb/ppc-netbsd-tdep.c +++ b/gdb/ppc-netbsd-tdep.c @@ -102,7 +102,7 @@ ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self, CORE_ADDR func) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR addr, base; int i; diff --git a/gdb/ppc-obsd-tdep.c b/gdb/ppc-obsd-tdep.c index 98b3e40..6a83c08 100644 --- a/gdb/ppc-obsd-tdep.c +++ b/gdb/ppc-obsd-tdep.c @@ -161,7 +161,7 @@ static struct trad_frame_cache * ppcobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *cache; CORE_ADDR addr, base, func; diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index d98af25..0d15e42 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -65,7 +65,7 @@ ppc_sysv_abi_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); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function)); ULONGEST saved_sp; @@ -597,7 +597,7 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (valtype->code () == TYPE_CODE_DECFLOAT); @@ -675,7 +675,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, gdb_byte *readbuf, const gdb_byte *writebuf, int broken_gcc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0; @@ -1250,7 +1250,7 @@ ppc64_sysv_abi_push_val (struct gdbarch *gdbarch, const bfd_byte *val, int len, int align, struct ppc64_sysv_argpos *argpos) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int offset = 0; /* Enforce alignment of stack location, if requested. */ @@ -1300,7 +1300,7 @@ static void ppc64_sysv_abi_push_integer (struct gdbarch *gdbarch, ULONGEST val, struct ppc64_sysv_argpos *argpos) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); gdb_byte buf[PPC_MAX_REGISTER_SIZE]; @@ -1318,7 +1318,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, struct type *type, const bfd_byte *val, struct ppc64_sysv_argpos *argpos) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->soft_float) return; @@ -1403,7 +1403,7 @@ static void ppc64_sysv_abi_push_vreg (struct gdbarch *gdbarch, const bfd_byte *val, struct ppc64_sysv_argpos *argpos) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (argpos->regcache && argpos->vreg <= 13) argpos->regcache->cooked_write (tdep->ppc_vr0_regnum + argpos->vreg, val); @@ -1419,7 +1419,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, struct type *type, const bfd_byte *val, struct ppc64_sysv_argpos *argpos) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (type->code () == TYPE_CODE_FLT || type->code () == TYPE_CODE_DECFLOAT) @@ -1545,7 +1545,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR struct_addr) { CORE_ADDR func_addr = find_function_addr (function, NULL); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int opencl_abi = ppc_sysv_use_opencl_abi (value_type (function)); ULONGEST back_chain; @@ -1739,7 +1739,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf, int index) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Integers live in GPRs starting at r3. */ if ((valtype->code () == TYPE_CODE_INT @@ -1905,7 +1905,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct type *func_type = function ? value_type (function) : NULL; int opencl_abi = func_type? ppc_sysv_use_opencl_abi (func_type) : 0; struct type *eltype; diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index 1e0754f..6b305c4 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -205,106 +205,106 @@ enum powerpc_long_double_abi POWERPC_LONG_DOUBLE_LAST }; -struct gdbarch_tdep +struct ppc_gdbarch_tdep : gdbarch_tdep { - int wordsize; /* Size in bytes of fixed-point word. */ - int soft_float; /* Avoid FP registers for arguments? */ + int wordsize = 0; /* Size in bytes of fixed-point word. */ + int soft_float = 0; /* Avoid FP registers for arguments? */ - enum powerpc_elf_abi elf_abi; /* ELF ABI version. */ + enum powerpc_elf_abi elf_abi {}; /* ELF ABI version. */ /* Format to use for the "long double" data type. */ - enum powerpc_long_double_abi long_double_abi; + enum powerpc_long_double_abi long_double_abi {}; /* How to pass vector arguments. Never set to AUTO or LAST. */ - enum powerpc_vector_abi vector_abi; + enum powerpc_vector_abi vector_abi {}; - int ppc_gp0_regnum; /* GPR register 0 */ - int ppc_toc_regnum; /* TOC register */ - int ppc_ps_regnum; /* Processor (or machine) status (%msr) */ - int ppc_cr_regnum; /* Condition register */ - int ppc_lr_regnum; /* Link register */ - int ppc_ctr_regnum; /* Count register */ - int ppc_xer_regnum; /* Integer exception register */ + int ppc_gp0_regnum = 0; /* GPR register 0 */ + int ppc_toc_regnum = 0; /* TOC register */ + int ppc_ps_regnum = 0; /* Processor (or machine) status (%msr) */ + int ppc_cr_regnum = 0; /* Condition register */ + int ppc_lr_regnum = 0; /* Link register */ + int ppc_ctr_regnum = 0; /* Count register */ + int ppc_xer_regnum = 0; /* Integer exception register */ /* Not all PPC and RS6000 variants will have the registers represented below. A -1 is used to indicate that the register is not present in this variant. */ /* Floating-point registers. */ - int ppc_fp0_regnum; /* Floating-point register 0. */ - int ppc_fpscr_regnum; /* fp status and condition register. */ + int ppc_fp0_regnum = 0; /* Floating-point register 0. */ + int ppc_fpscr_regnum = 0; /* fp status and condition register. */ /* Multiplier-Quotient Register (older POWER architectures only). */ - int ppc_mq_regnum; + int ppc_mq_regnum = 0; /* POWER7 VSX registers. */ - int ppc_vsr0_regnum; /* First VSX register. */ - int ppc_vsr0_upper_regnum; /* First right most dword vsx register. */ - int ppc_efpr0_regnum; /* First Extended FP register. */ + int ppc_vsr0_regnum = 0; /* First VSX register. */ + int ppc_vsr0_upper_regnum = 0; /* First right most dword vsx register. */ + int ppc_efpr0_regnum = 0; /* First Extended FP register. */ /* Altivec registers. */ - int ppc_vr0_regnum; /* First AltiVec register. */ - int ppc_vrsave_regnum; /* Last AltiVec register. */ + int ppc_vr0_regnum = 0; /* First AltiVec register. */ + int ppc_vrsave_regnum = 0; /* Last AltiVec register. */ /* Altivec pseudo-register vX aliases for the raw vrX registers. */ - int ppc_v0_alias_regnum; + int ppc_v0_alias_regnum = 0; /* SPE registers. */ - int ppc_ev0_upper_regnum; /* First GPR upper half register. */ - int ppc_ev0_regnum; /* First ev register. */ - int ppc_acc_regnum; /* SPE 'acc' register. */ - int ppc_spefscr_regnum; /* SPE 'spefscr' register. */ + int ppc_ev0_upper_regnum = 0; /* First GPR upper half register. */ + int ppc_ev0_regnum = 0; /* First ev register. */ + int ppc_acc_regnum = 0; /* SPE 'acc' register. */ + int ppc_spefscr_regnum = 0; /* SPE 'spefscr' register. */ /* Program Priority Register. */ - int ppc_ppr_regnum; + int ppc_ppr_regnum = 0; /* Data Stream Control Register. */ - int ppc_dscr_regnum; + int ppc_dscr_regnum = 0; /* Target Address Register. */ - int ppc_tar_regnum; + int ppc_tar_regnum = 0; /* Decimal 128 registers. */ - int ppc_dl0_regnum; /* First Decimal128 argument register pair. */ + int ppc_dl0_regnum = 0; /* First Decimal128 argument register pair. */ - int have_ebb; + int have_ebb = 0; /* PMU registers. */ - int ppc_mmcr0_regnum; - int ppc_mmcr2_regnum; - int ppc_siar_regnum; - int ppc_sdar_regnum; - int ppc_sier_regnum; + int ppc_mmcr0_regnum = 0; + int ppc_mmcr2_regnum = 0; + int ppc_siar_regnum = 0; + int ppc_sdar_regnum = 0; + int ppc_sier_regnum = 0; /* Hardware Transactional Memory registers. */ - int have_htm_spr; - int have_htm_core; - int have_htm_fpu; - int have_htm_altivec; - int have_htm_vsx; - int ppc_cppr_regnum; - int ppc_cdscr_regnum; - int ppc_ctar_regnum; + int have_htm_spr = 0; + int have_htm_core = 0; + int have_htm_fpu = 0; + int have_htm_altivec = 0; + int have_htm_vsx = 0; + int ppc_cppr_regnum = 0; + int ppc_cdscr_regnum = 0; + int ppc_ctar_regnum = 0; /* HTM pseudo registers. */ - int ppc_cdl0_regnum; - int ppc_cvsr0_regnum; - int ppc_cefpr0_regnum; + int ppc_cdl0_regnum = 0; + int ppc_cvsr0_regnum = 0; + int ppc_cefpr0_regnum = 0; /* Offset to ABI specific location where link register is saved. */ - int lr_frame_offset; + int lr_frame_offset = 0; /* An array of integers, such that sim_regno[I] is the simulator register number for GDB register number I, or -1 if the simulator does not implement that register. */ - int *sim_regno; + int *sim_regno = nullptr; /* ISA-specific types. */ - struct type *ppc_builtin_type_vec64; - struct type *ppc_builtin_type_vec128; + struct type *ppc_builtin_type_vec64 = nullptr; + struct type *ppc_builtin_type_vec128 = nullptr; - int (*ppc_syscall_record) (struct regcache *regcache); + int (*ppc_syscall_record) (struct regcache *regcache) = nullptr; }; diff --git a/gdb/ppc64-tdep.c b/gdb/ppc64-tdep.c index 1dd94f2..aab893d 100644 --- a/gdb/ppc64-tdep.c +++ b/gdb/ppc64-tdep.c @@ -89,7 +89,7 @@ ppc64_plt_entry_point (struct frame_info *frame, CORE_ADDR plt_off) { struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); CORE_ADDR tocp; if (execution_direction == EXEC_REVERSE) diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c index 7351e19..f6489ab 100644 --- a/gdb/riscv-linux-tdep.c +++ b/gdb/riscv-linux-tdep.c @@ -179,7 +179,7 @@ riscv_linux_syscall_next_pc (struct frame_info *frame) static void riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index bfd93c6..a6a64d3 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -730,7 +730,8 @@ show_riscv_debug_variable (struct ui_file *file, int from_tty, int riscv_isa_xlen (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->isa_features.xlen; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->isa_features.xlen; } /* See riscv-tdep.h. */ @@ -738,7 +739,8 @@ riscv_isa_xlen (struct gdbarch *gdbarch) int riscv_abi_xlen (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->abi_features.xlen; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->abi_features.xlen; } /* See riscv-tdep.h. */ @@ -746,7 +748,8 @@ riscv_abi_xlen (struct gdbarch *gdbarch) int riscv_isa_flen (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->isa_features.flen; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->isa_features.flen; } /* See riscv-tdep.h. */ @@ -754,7 +757,8 @@ riscv_isa_flen (struct gdbarch *gdbarch) int riscv_abi_flen (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->abi_features.flen; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->abi_features.flen; } /* See riscv-tdep.h. */ @@ -762,7 +766,8 @@ riscv_abi_flen (struct gdbarch *gdbarch) bool riscv_abi_embedded (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->abi_features.embedded; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->abi_features.embedded; } /* Return true if the target for GDBARCH has floating point hardware. */ @@ -778,7 +783,8 @@ riscv_has_fp_regs (struct gdbarch *gdbarch) static bool riscv_has_fp_abi (struct gdbarch *gdbarch) { - return gdbarch_tdep (gdbarch)->abi_features.flen > 0; + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); + return tdep->abi_features.flen > 0; } /* Return true if REGNO is a floating pointer register. */ @@ -901,7 +907,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum) will show up in 'info register all'. Unless, we identify the duplicate copies of these registers (in riscv_tdesc_unknown_reg) and then hide the registers here by giving them no name. */ - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->duplicate_fflags_regnum == regnum) return NULL; if (tdep->duplicate_frm_regnum == regnum) @@ -929,7 +935,7 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum) static struct type * riscv_fpreg_d_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->riscv_fpreg_d_type == nullptr) { @@ -1251,7 +1257,7 @@ riscv_is_regnum_a_named_csr (int regnum) static bool riscv_is_unknown_csr (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); return (regnum >= tdep->unknown_csrs_first_regnum && regnum < (tdep->unknown_csrs_first_regnum + tdep->unknown_csrs_count)); @@ -3560,7 +3566,7 @@ riscv_tdesc_unknown_reg (struct gdbarch *gdbarch, tdesc_feature *feature, record their register numbers here. */ if (strcmp (tdesc_feature_name (feature), riscv_freg_feature.name ()) == 0) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); int *regnum_ptr = nullptr; if (strcmp (reg_name, "fflags") == 0) @@ -3591,7 +3597,7 @@ riscv_tdesc_unknown_reg (struct gdbarch *gdbarch, tdesc_feature *feature, about register groups in riscv_register_reggroup_p. */ if (strcmp (tdesc_feature_name (feature), riscv_csr_feature.name ()) == 0) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + riscv_gdbarch_tdep *tdep = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->unknown_csrs_first_regnum == -1) tdep->unknown_csrs_first_regnum = possible_regnum; gdb_assert (tdep->unknown_csrs_first_regnum @@ -3628,7 +3634,6 @@ riscv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; struct riscv_gdbarch_features features; const struct target_desc *tdesc = info.target_desc; @@ -3693,7 +3698,8 @@ riscv_gdbarch_init (struct gdbarch_info info, /* Check that the feature set of the ARCHES matches the feature set we are looking for. If it doesn't then we can't reuse this gdbarch. */ - struct gdbarch_tdep *other_tdep = gdbarch_tdep (arches->gdbarch); + riscv_gdbarch_tdep *other_tdep + = (riscv_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); if (other_tdep->isa_features != features || other_tdep->abi_features != abi_features) @@ -3706,7 +3712,7 @@ riscv_gdbarch_init (struct gdbarch_info info, return arches->gdbarch; /* None found, so create a new architecture from the information provided. */ - tdep = new (struct gdbarch_tdep); + riscv_gdbarch_tdep *tdep = new riscv_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->isa_features = features; tdep->abi_features = abi_features; @@ -3812,7 +3818,8 @@ static CORE_ADDR riscv_next_pc (struct regcache *regcache, CORE_ADDR pc) { struct gdbarch *gdbarch = regcache->arch (); - const struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + const riscv_gdbarch_tdep *tdep + = (riscv_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct riscv_insn insn; CORE_ADDR next_pc; diff --git a/gdb/riscv-tdep.h b/gdb/riscv-tdep.h index 03870cf..2af6ec3 100644 --- a/gdb/riscv-tdep.h +++ b/gdb/riscv-tdep.h @@ -22,6 +22,7 @@ #define RISCV_TDEP_H #include "arch/riscv.h" +#include "gdbarch.h" /* RiscV register numbers. */ enum @@ -75,7 +76,7 @@ enum }; /* RISC-V specific per-architecture information. */ -struct gdbarch_tdep +struct riscv_gdbarch_tdep : gdbarch_tdep { /* Features about the target hardware that impact how the gdbarch is configured. Two gdbarch instances are compatible only if this field @@ -105,7 +106,7 @@ struct gdbarch_tdep /* Return the expected next PC assuming FRAME is stopped at a syscall instruction. */ - CORE_ADDR (*syscall_next_pc) (struct frame_info *frame); + CORE_ADDR (*syscall_next_pc) (struct frame_info *frame) = nullptr; }; diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 3b2cf96..616dafb 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -209,21 +209,21 @@ enum /* Architecture specific data. */ -struct gdbarch_tdep +struct rl78_gdbarch_tdep : gdbarch_tdep { /* The ELF header flags specify the multilib used. */ - int elf_flags; - - struct type *rl78_void, - *rl78_uint8, - *rl78_int8, - *rl78_uint16, - *rl78_int16, - *rl78_uint32, - *rl78_int32, - *rl78_data_pointer, - *rl78_code_pointer, - *rl78_psw_type; + int elf_flags = 0; + + struct type *rl78_void = nullptr, + *rl78_uint8 = nullptr, + *rl78_int8 = nullptr, + *rl78_uint16 = nullptr, + *rl78_int16 = nullptr, + *rl78_uint32 = nullptr, + *rl78_int32 = nullptr, + *rl78_data_pointer = nullptr, + *rl78_code_pointer = nullptr, + *rl78_psw_type = nullptr; }; /* This structure holds the results of a prologue analysis. */ @@ -266,7 +266,7 @@ struct rl78_prologue static struct type * rl78_psw_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + rl78_gdbarch_tdep *tdep = (rl78_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->rl78_psw_type == NULL) { @@ -290,7 +290,7 @@ rl78_psw_type (struct gdbarch *gdbarch) static struct type * rl78_register_type (struct gdbarch *gdbarch, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + rl78_gdbarch_tdep *tdep = (rl78_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (reg_nr == RL78_PC_REGNUM) return tdep->rl78_code_pointer; @@ -1247,7 +1247,8 @@ rl78_return_value (struct gdbarch *gdbarch, { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST valtype_len = TYPE_LENGTH (valtype); - int is_g10 = gdbarch_tdep (gdbarch)->elf_flags & E_FLAG_RL78_G10; + rl78_gdbarch_tdep *tdep = (rl78_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int is_g10 = tdep->elf_flags & E_FLAG_RL78_G10; if (valtype_len > 8) return RETURN_VALUE_STRUCT_CONVENTION; @@ -1375,7 +1376,6 @@ static struct gdbarch * rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int elf_flags; /* Extract the elf_flags if available. */ @@ -1392,7 +1392,10 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags) + rl78_gdbarch_tdep *tdep + = (rl78_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->elf_flags != elf_flags) continue; return arches->gdbarch; @@ -1400,7 +1403,7 @@ rl78_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + rl78_gdbarch_tdep * tdep = new rl78_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 80e1957..11cae6a 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -73,7 +73,7 @@ aix_sighandle_frame_cache (struct frame_info *this_frame, LONGEST backchain; CORE_ADDR base, base_orig, func; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct trad_frame_cache *this_trad_cache; @@ -259,7 +259,8 @@ rs6000_aix_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - if (gdbarch_tdep (gdbarch)->wordsize == 4) + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->wordsize == 4) cb (".reg", 592, 592, &rs6000_aix32_regset, NULL, cb_data); else cb (".reg", 576, 576, &rs6000_aix64_regset, NULL, cb_data); @@ -289,7 +290,7 @@ rs6000_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); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int ii; int len = 0; @@ -297,7 +298,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int argbytes; /* current argument byte */ gdb_byte tmp_buffer[50]; int f_argno = 0; /* current floating point argno */ - int wordsize = gdbarch_tdep (gdbarch)->wordsize; + int wordsize = tdep->wordsize; CORE_ADDR func_addr = find_function_addr (function, NULL); struct value *arg = 0; @@ -519,7 +520,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); /* The calling convention this function implements assumes the @@ -657,7 +658,7 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct obj_section *s; @@ -701,7 +702,7 @@ branch_dest (struct regcache *regcache, int opcode, int instr, CORE_ADDR pc, CORE_ADDR safety) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR dest; int immediate; @@ -969,7 +970,7 @@ static struct ld_info rs6000_aix_extract_ld_info (struct gdbarch *gdbarch, const gdb_byte *ldi_buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; const struct ld_info_desc desc @@ -1128,7 +1129,7 @@ rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, static void rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* RS6000/AIX does not support PT_STEP. Has to be simulated. */ set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step); diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index 21f1baf..bdc1aaa 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -36,7 +36,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, function_call_return_method return_method, CORE_ADDR struct_addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int ii; int len = 0; @@ -44,7 +44,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, int argbytes; /* current argument byte */ gdb_byte tmp_buffer[50]; int f_argno = 0; /* current floating point argno */ - int wordsize = gdbarch_tdep (gdbarch)->wordsize; + int wordsize = tdep->wordsize; struct value *arg = 0; struct type *type; @@ -265,7 +265,7 @@ rs6000_lynx178_return_value (struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); /* The calling convention this function implements assumes the diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 4830ed2..0d61894 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -209,7 +209,7 @@ struct rs6000_framedata int vsx_register_p (struct gdbarch *gdbarch, int regno) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->ppc_vsr0_regnum < 0) return 0; else @@ -221,7 +221,7 @@ vsx_register_p (struct gdbarch *gdbarch, int regno) int altivec_register_p (struct gdbarch *gdbarch, int regno) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->ppc_vr0_regnum < 0 || tdep->ppc_vrsave_regnum < 0) return 0; else @@ -233,7 +233,7 @@ altivec_register_p (struct gdbarch *gdbarch, int regno) int spe_register_p (struct gdbarch *gdbarch, int regno) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Is it a reference to EV0 -- EV31, and do we have those? */ if (IS_SPE_PSEUDOREG (tdep, regno)) @@ -265,7 +265,7 @@ spe_register_p (struct gdbarch *gdbarch, int regno) int ppc_floating_point_unit_p (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); return (tdep->ppc_fp0_regnum >= 0 && tdep->ppc_fpscr_regnum >= 0); @@ -276,7 +276,7 @@ ppc_floating_point_unit_p (struct gdbarch *gdbarch) int ppc_altivec_support_p (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); return (tdep->ppc_vr0_regnum >= 0 && tdep->ppc_vrsave_regnum >= 0); @@ -305,7 +305,7 @@ set_sim_regno (int *table, int gdb_regno, int sim_regno) static void init_sim_regno_table (struct gdbarch *arch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (arch); int total_regs = gdbarch_num_regs (arch); int *sim_regno = GDBARCH_OBSTACK_CALLOC (arch, total_regs, int); int i; @@ -399,7 +399,7 @@ init_sim_regno_table (struct gdbarch *arch) static int rs6000_register_sim_regno (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int sim_regno; if (tdep->sim_regno == NULL) @@ -470,7 +470,7 @@ ppc_collect_reg (const struct regcache *regcache, int regnum, static int ppc_greg_offset (struct gdbarch *gdbarch, - struct gdbarch_tdep *tdep, + ppc_gdbarch_tdep *tdep, const struct ppc_reg_offsets *offsets, int regnum, int *regsize) @@ -507,7 +507,7 @@ ppc_greg_offset (struct gdbarch *gdbarch, } static int -ppc_fpreg_offset (struct gdbarch_tdep *tdep, +ppc_fpreg_offset (ppc_gdbarch_tdep *tdep, const struct ppc_reg_offsets *offsets, int regnum) { @@ -530,7 +530,7 @@ ppc_supply_gregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct ppc_reg_offsets *offsets = (const struct ppc_reg_offsets *) regset->regmap; size_t offset; @@ -580,14 +580,13 @@ ppc_supply_fpregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep; const struct ppc_reg_offsets *offsets; size_t offset; if (!ppc_floating_point_unit_p (gdbarch)) return; - tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); offsets = (const struct ppc_reg_offsets *) regset->regmap; if (regnum == -1) { @@ -620,7 +619,7 @@ ppc_collect_gregset (const struct regset *regset, int regnum, void *gregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct ppc_reg_offsets *offsets = (const struct ppc_reg_offsets *) regset->regmap; size_t offset; @@ -671,14 +670,13 @@ ppc_collect_fpregset (const struct regset *regset, int regnum, void *fpregs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep; const struct ppc_reg_offsets *offsets; size_t offset; if (!ppc_floating_point_unit_p (gdbarch)) return; - tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); offsets = (const struct ppc_reg_offsets *) regset->regmap; if (regnum == -1) { @@ -756,7 +754,7 @@ static int rs6000_in_function_epilogue_frame_p (struct frame_info *curfrm, struct gdbarch *gdbarch, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); bfd_byte insn_buf[PPC_INSN_SIZE]; CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end; @@ -1052,8 +1050,9 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch, if (insn & 0x1) { /* Link register needs to be set to the next instruction's PC. */ + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); regcache_cooked_write_unsigned (regs, - gdbarch_tdep (gdbarch)->ppc_lr_regnum, + tdep->ppc_lr_regnum, from + PPC_INSN_SIZE); displaced_debug_printf ("(ppc) adjusted LR to %s", paddress (gdbarch, from + PPC_INSN_SIZE)); @@ -1599,7 +1598,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc, int num_skip_non_prologue_insns = 0; int r0_contains_arg = 0; const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); memset (fdata, 0, sizeof (struct rs6000_framedata)); @@ -2319,7 +2318,7 @@ static CORE_ADDR rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int ii, op; int rel; @@ -2377,7 +2376,7 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) static struct type * rs6000_builtin_type_vec64 (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->ppc_builtin_type_vec64) { @@ -2422,7 +2421,7 @@ rs6000_builtin_type_vec64 (struct gdbarch *gdbarch) static struct type * rs6000_builtin_type_vec128 (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->ppc_builtin_type_vec128) { @@ -2476,7 +2475,7 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch) static const char * rs6000_register_name (struct gdbarch *gdbarch, int regno) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* The upper half "registers" have names in the XML description, but we present only the low GPRs and the full 64-bit registers @@ -2614,7 +2613,7 @@ rs6000_register_name (struct gdbarch *gdbarch, int regno) static struct type * rs6000_pseudo_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* These are the e500 pseudo-registers. */ if (IS_SPE_PSEUDOREG (tdep, regnum)) @@ -2653,7 +2652,7 @@ static int rs6000_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *group) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (IS_V_ALIAS_PSEUDOREG (tdep, regnum)) return 0; @@ -2668,7 +2667,7 @@ static int rs6000_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); return (tdep->ppc_fp0_regnum >= 0 && regnum >= tdep->ppc_fp0_regnum @@ -2753,7 +2752,7 @@ e500_move_ev_register (move_ev_register_func move, struct regcache *regcache, int ev_reg, void *buffer) { struct gdbarch *arch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (arch); int reg_index; gdb_byte *byte_buffer = (gdb_byte *) buffer; enum register_status status; @@ -2794,7 +2793,7 @@ e500_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int ev_reg, gdb_byte *buffer) { struct gdbarch *arch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index; enum register_status status; @@ -2835,7 +2834,7 @@ static enum register_status dfp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int reg_nr, gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, fp0; enum register_status status; @@ -2875,7 +2874,7 @@ static void dfp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int reg_nr, const gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, fp0; if (IS_DFP_PSEUDOREG (tdep, reg_nr)) @@ -2912,7 +2911,7 @@ v_alias_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int reg_nr, gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr)); return regcache->raw_read (tdep->ppc_vr0_regnum @@ -2927,7 +2926,7 @@ v_alias_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int reg_nr, const gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr)); regcache->raw_write (tdep->ppc_vr0_regnum @@ -2939,7 +2938,7 @@ static enum register_status vsx_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int reg_nr, gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0, fp0, vsr0_upper; enum register_status status; @@ -2987,7 +2986,7 @@ static void vsx_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int reg_nr, const gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0, fp0, vsr0_upper; if (IS_VSX_PSEUDOREG (tdep, reg_nr)) @@ -3029,7 +3028,7 @@ static enum register_status efp_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int reg_nr, gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0; if (IS_EFP_PSEUDOREG (tdep, reg_nr)) @@ -3058,7 +3057,7 @@ static void efp_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int reg_nr, const gdb_byte *buffer) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0; int offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 0 : 8; @@ -3094,7 +3093,7 @@ rs6000_pseudo_register_read (struct gdbarch *gdbarch, int reg_nr, gdb_byte *buffer) { struct gdbarch *regcache_arch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (regcache_arch == gdbarch); @@ -3125,7 +3124,7 @@ rs6000_pseudo_register_write (struct gdbarch *gdbarch, int reg_nr, const gdb_byte *buffer) { struct gdbarch *regcache_arch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (regcache_arch == gdbarch); @@ -3156,7 +3155,7 @@ static void dfp_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, fp0; if (IS_DFP_PSEUDOREG (tdep, reg_nr)) @@ -3183,7 +3182,7 @@ static void v_alias_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_assert (IS_V_ALIAS_PSEUDOREG (tdep, reg_nr)); ax_reg_mask (ax, tdep->ppc_vr0_regnum @@ -3197,7 +3196,7 @@ static void vsx_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0, fp0, vsr0_upper; if (IS_VSX_PSEUDOREG (tdep, reg_nr)) @@ -3235,7 +3234,7 @@ static void efp_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int reg_index, vr0; if (IS_EFP_PSEUDOREG (tdep, reg_nr)) @@ -3258,7 +3257,7 @@ static int rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg_nr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (IS_SPE_PSEUDOREG (tdep, reg_nr)) { int reg_index = reg_nr - tdep->ppc_ev0_regnum; @@ -3298,7 +3297,7 @@ rs6000_gen_return_address (struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); value->type = register_type (gdbarch, tdep->ppc_lr_regnum); value->kind = axs_lvalue_register; value->u.reg = tdep->ppc_lr_regnum; @@ -3309,7 +3308,7 @@ rs6000_gen_return_address (struct gdbarch *gdbarch, static int rs6000_stab_reg_to_regnum (struct gdbarch *gdbarch, int num) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (0 <= num && num <= 31) return tdep->ppc_gp0_regnum + num; @@ -3351,7 +3350,7 @@ rs6000_stab_reg_to_regnum (struct gdbarch *gdbarch, int num) static int rs6000_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int num) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (0 <= num && num <= 31) return tdep->ppc_gp0_regnum + num; @@ -3570,7 +3569,7 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache) { struct rs6000_frame_cache *cache; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct rs6000_framedata fdata; int wordsize = tdep->wordsize; @@ -3806,7 +3805,7 @@ rs6000_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache) { struct rs6000_frame_cache *cache; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (*this_cache) return (struct rs6000_frame_cache *) *this_cache; @@ -3927,7 +3926,7 @@ ppc_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* PPC32 and PPC64 ABI's are the same regarding volatile and non-volatile registers. We will use the same code for both. */ @@ -4139,7 +4138,7 @@ bfd_uses_spe_extensions (bfd *abfd) Otherwise, it's just a VR register. Record them accordingly. */ static int -ppc_record_vsr (struct regcache *regcache, struct gdbarch_tdep *tdep, int vsr) +ppc_record_vsr (struct regcache *regcache, ppc_gdbarch_tdep *tdep, int vsr) { if (vsr < 0 || vsr >= 64) return -1; @@ -4168,7 +4167,7 @@ static int ppc_process_record_op4 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_FIELD (insn, 21, 11); int vra = PPC_FIELD (insn, 11, 5); @@ -4541,7 +4540,7 @@ static int ppc_process_record_op19 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_EXTOP (insn); switch (ext & 0x01f) @@ -4593,7 +4592,7 @@ static int ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_EXTOP (insn); int tmp, nr, nb, i; CORE_ADDR at_dcsz, ea = 0; @@ -5190,7 +5189,7 @@ static int ppc_process_record_op59 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_EXTOP (insn); switch (ext & 0x1f) @@ -5284,7 +5283,7 @@ static int ppc_process_record_op60 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_EXTOP (insn); switch (ext >> 2) @@ -5646,7 +5645,7 @@ static int ppc_process_record_op61 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST ea = 0; int size; @@ -5705,7 +5704,7 @@ static int ppc_process_record_op63 (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr, uint32_t insn) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ext = PPC_EXTOP (insn); int tmp; @@ -5964,7 +5963,7 @@ int ppc_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); uint32_t insn; int op6, tmp, i; @@ -6267,7 +6266,6 @@ static struct gdbarch * rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int wordsize, from_xcoff_exec, from_elf_exec; enum bfd_architecture arch; unsigned long mach; @@ -6953,7 +6951,8 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Word size in the various PowerPC bfd_arch_info structs isn't meaningful, because 64-bit CPUs can run in 32-bit mode. So, perform separate word size check. */ - tdep = gdbarch_tdep (arches->gdbarch); + ppc_gdbarch_tdep *tdep + = (ppc_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); if (tdep && tdep->elf_abi != elf_abi) continue; if (tdep && tdep->soft_float != soft_float) @@ -6974,7 +6973,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - "set arch" trust blindly - GDB startup useless but harmless */ - tdep = XCNEW (struct gdbarch_tdep); + ppc_gdbarch_tdep *tdep = new ppc_gdbarch_tdep; tdep->wordsize = wordsize; tdep->elf_abi = elf_abi; tdep->soft_float = soft_float; @@ -7253,7 +7252,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static void rs6000_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + ppc_gdbarch_tdep *tdep = (ppc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep == NULL) return; diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 2d20aed..73e708b 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -68,16 +68,16 @@ enum rx_frame_type { }; /* Architecture specific data. */ -struct gdbarch_tdep +struct rx_gdbarch_tdep : gdbarch_tdep { /* The ELF header flags specify the multilib used. */ - int elf_flags; + int elf_flags = 0; /* Type of PSW and BPSW. */ - struct type *rx_psw_type; + struct type *rx_psw_type = nullptr; /* Type of FPSW. */ - struct type *rx_fpsw_type; + struct type *rx_fpsw_type = nullptr; }; /* This structure holds the results of a prologue analysis. */ @@ -944,7 +944,6 @@ static struct gdbarch * rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int elf_flags; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; @@ -963,7 +962,10 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags) + rx_gdbarch_tdep *tdep + = (rx_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->elf_flags != elf_flags) continue; return arches->gdbarch; @@ -994,7 +996,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdb_assert(tdesc_data != NULL); - tdep = XCNEW (struct gdbarch_tdep); + rx_gdbarch_tdep *tdep = new rx_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c index faf63c4..ca4fe0a 100644 --- a/gdb/s12z-tdep.c +++ b/gdb/s12z-tdep.c @@ -482,7 +482,7 @@ constexpr gdb_byte s12z_break_insn[] = {0x00}; typedef BP_MANIPULATION (s12z_break_insn) s12z_breakpoint; -struct gdbarch_tdep +struct s12z_gdbarch_tdep : gdbarch_tdep { }; @@ -640,7 +640,7 @@ show_bdccsr_command (const char *args, int from_tty) static struct gdbarch * s12z_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep = XNEW (struct gdbarch_tdep); + s12z_gdbarch_tdep *tdep = new s12z_gdbarch_tdep; struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); add_cmd ("bdccsr", class_support, show_bdccsr_command, diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 04e3fc6..3fa0b65 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -79,7 +79,7 @@ static void s390_write_pc (struct regcache *regcache, CORE_ADDR pc) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc); @@ -269,7 +269,7 @@ s390_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); const int gregset_size = (tdep->abi == ABI_LINUX_S390 ? s390_sizeof_gregset : s390x_sizeof_gregset); @@ -390,7 +390,7 @@ s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame, void **this_prologue_cache) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int word_size = gdbarch_ptr_bit (gdbarch) / 8; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); struct s390_sigtramp_unwind_cache *info; @@ -561,7 +561,7 @@ s390_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread) { struct regcache *regs = get_thread_regcache (thread); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST pc; ULONGEST svc_number = -1; @@ -594,7 +594,7 @@ static int s390_all_but_pc_registers_record (struct regcache *regcache) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int i; for (i = 0; i < 16; i++) @@ -802,7 +802,7 @@ static int s390_linux_syscall_record (struct regcache *regcache, LONGEST syscall_native) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int ret; enum gdb_syscall syscall_gdb; @@ -852,7 +852,7 @@ static int s390_linux_record_signal (struct gdbarch *gdbarch, struct regcache *regcache, enum gdb_signal signal) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* There are two kinds of signal frames on s390. rt_sigframe is always the larger one, so don't even bother with sigframe. */ const int sizeof_rt_sigframe = (tdep->abi == ABI_LINUX_ZSERIES ? @@ -1116,7 +1116,7 @@ s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep, static void s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->s390_syscall_record = s390_linux_syscall_record; @@ -1151,7 +1151,7 @@ s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch) static void s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->abi = ABI_LINUX_S390; @@ -1167,7 +1167,7 @@ s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch) static void s390_linux_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->abi = ABI_LINUX_ZSERIES; diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 0a4a574..abbb094 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1045,7 +1045,7 @@ s390_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) static int s390_register_call_saved (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); switch (tdep->abi) { @@ -1076,7 +1076,7 @@ s390_guess_tracepoint_registers (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int sz = register_size (gdbarch, S390_PSWA_REGNUM); gdb_byte *reg = (gdb_byte *) alloca (sz); ULONGEST pswm, pswa; @@ -1172,7 +1172,7 @@ enum { s390_dwarf_reg_r0l = ARRAY_SIZE (s390_dwarf_regmap) - 16 }; static int s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int gdb_reg = -1; /* In a 32-on-64 debug scenario, debug info refers to the full @@ -1205,7 +1205,7 @@ s390_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) These pseudo-registers are composed of two adjacent gprs. */ static int -regnum_is_gpr_full (struct gdbarch_tdep *tdep, int regnum) +regnum_is_gpr_full (s390_gdbarch_tdep *tdep, int regnum) { return (tdep->gpr_full_regnum != -1 && regnum >= tdep->gpr_full_regnum @@ -1216,7 +1216,7 @@ regnum_is_gpr_full (struct gdbarch_tdep *tdep, int regnum) These pseudo-registers are composed of f0-f15 and v0l-v15l. */ static int -regnum_is_vxr_full (struct gdbarch_tdep *tdep, int regnum) +regnum_is_vxr_full (s390_gdbarch_tdep *tdep, int regnum) { return (tdep->v0_full_regnum != -1 && regnum >= tdep->v0_full_regnum @@ -1231,7 +1231,7 @@ static struct value * s390_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_id frame_id) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct value *value = default_value_from_register (gdbarch, type, regnum, frame_id); check_typedef (type); @@ -1250,7 +1250,7 @@ s390_value_from_register (struct gdbarch *gdbarch, struct type *type, static const char * s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum == tdep->pc_regnum) return "pc"; @@ -1284,7 +1284,7 @@ s390_pseudo_register_name (struct gdbarch *gdbarch, int regnum) static struct type * s390_pseudo_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum == tdep->pc_regnum) return builtin_type (gdbarch)->builtin_func_ptr; @@ -1308,7 +1308,7 @@ static enum register_status s390_pseudo_register_read (struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int regsize = register_size (gdbarch, regnum); ULONGEST val; @@ -1383,7 +1383,7 @@ static void s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int regsize = register_size (gdbarch, regnum); ULONGEST val, psw; @@ -1442,7 +1442,7 @@ static int s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *group) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* We usually save/restore the whole PSW, which includes PC and CC. However, some older gdbservers may not support saving/restoring @@ -1470,7 +1470,7 @@ static int s390_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum == tdep->pc_regnum) { ax_reg_mask (ax, S390_PSWA_REGNUM); @@ -1504,7 +1504,7 @@ static int s390_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, struct agent_expr *ax, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum == tdep->pc_regnum) { ax_reg (ax, S390_PSWA_REGNUM); @@ -1746,7 +1746,7 @@ struct s390_arg_state static void s390_handle_arg (struct s390_arg_state *as, struct value *arg, - struct gdbarch_tdep *tdep, int word_size, + s390_gdbarch_tdep *tdep, int word_size, enum bfd_endian byte_order, int is_unnamed) { struct type *type = check_typedef (value_type (arg)); @@ -1905,7 +1905,7 @@ s390_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); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); int word_size = gdbarch_ptr_bit (gdbarch) / 8; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); int i; @@ -2083,11 +2083,14 @@ s390_return_value (struct gdbarch *gdbarch, struct value *function, rvc = RETURN_VALUE_STRUCT_CONVENTION; break; case TYPE_CODE_ARRAY: - rvc = (gdbarch_tdep (gdbarch)->vector_abi == S390_VECTOR_ABI_128 - && TYPE_LENGTH (type) <= 16 && type->is_vector ()) - ? RETURN_VALUE_REGISTER_CONVENTION - : RETURN_VALUE_STRUCT_CONVENTION; - break; + { + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); + rvc = (tdep->vector_abi == S390_VECTOR_ABI_128 + && TYPE_LENGTH (type) <= 16 && type->is_vector ()) + ? RETURN_VALUE_REGISTER_CONVENTION + : RETURN_VALUE_STRUCT_CONVENTION; + break; + } default: rvc = TYPE_LENGTH (type) <= 8 ? RETURN_VALUE_REGISTER_CONVENTION @@ -2165,7 +2168,7 @@ s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) static CORE_ADDR s390_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST pc; pc = frame_unwind_register_unsigned (next_frame, tdep->pc_regnum); return gdbarch_addr_bits_remove (gdbarch, pc); @@ -2187,7 +2190,7 @@ static struct value * s390_unwind_pseudo_register (struct frame_info *this_frame, int regnum) { struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); struct type *type = register_type (gdbarch, regnum); /* Unwind PC via PSW address. */ @@ -2772,7 +2775,7 @@ static CORE_ADDR s390_record_address_mask (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR val) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); ULONGEST pswm, pswa; int am; if (tdep->abi == ABI_LINUX_S390) @@ -2839,7 +2842,7 @@ s390_record_calc_disp_vsce (struct gdbarch *gdbarch, struct regcache *regcache, uint8_t vx, uint8_t el, uint8_t es, uint16_t bd, int8_t dh, CORE_ADDR *res) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); ULONGEST x; gdb_byte buf[16]; @@ -2882,7 +2885,7 @@ static int s390_popcnt (unsigned int x) { static int s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (record_full_arch_list_add_reg (regcache, S390_R0_REGNUM + i)) return -1; if (tdep->abi == ABI_LINUX_S390) @@ -2896,7 +2899,7 @@ s390_record_gpr_g (struct gdbarch *gdbarch, struct regcache *regcache, int i) static int s390_record_gpr_h (struct gdbarch *gdbarch, struct regcache *regcache, int i) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->abi == ABI_LINUX_S390) { if (record_full_arch_list_add_reg (regcache, S390_R0_UPPER_REGNUM + i)) @@ -2936,7 +2939,7 @@ static int s390_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + s390_gdbarch_tdep *tdep = (s390_gdbarch_tdep *) gdbarch_tdep (gdbarch); uint16_t insn[3] = {0}; /* Instruction as bytes. */ uint8_t ibyte[6]; @@ -6831,7 +6834,7 @@ while (0) tdesc. */ static bool -s390_tdesc_valid (struct gdbarch_tdep *tdep, +s390_tdesc_valid (s390_gdbarch_tdep *tdep, struct tdesc_arch_data *tdesc_data) { static const char *const psw[] = { @@ -6983,10 +6986,10 @@ s390_tdesc_valid (struct gdbarch_tdep *tdep, /* Allocate and initialize new gdbarch_tdep. Caller is responsible to free memory after use. */ -static struct gdbarch_tdep * +static s390_gdbarch_tdep * s390_gdbarch_tdep_alloc () { - struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep); + s390_gdbarch_tdep *tdep = new s390_gdbarch_tdep; tdep->tdesc = NULL; @@ -7023,7 +7026,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) static const char *const stap_register_indirection_suffixes[] = { ")", NULL }; - struct gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc (); + s390_gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc (); struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); info.tdesc_data = tdesc_data.get (); @@ -7153,7 +7156,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Check any target description for validity. */ if (!s390_tdesc_valid (tdep, tdesc_data.get ())) { - xfree (tdep); + delete tdep; gdbarch_free (gdbarch); return NULL; } @@ -7174,16 +7177,19 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - struct gdbarch_tdep *tmp = gdbarch_tdep (arches->gdbarch); + s390_gdbarch_tdep *tmp + = (s390_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + if (!tmp) continue; + /* A program can 'choose' not to use the vector registers when they are present. Leading to the same tdesc but different tdep and thereby a different gdbarch. */ if (tmp->vector_abi != tdep->vector_abi) continue; - xfree (tdep); + delete tdep; gdbarch_free (gdbarch); return arches->gdbarch; } diff --git a/gdb/s390-tdep.h b/gdb/s390-tdep.h index 8c9d75a..191977e 100644 --- a/gdb/s390-tdep.h +++ b/gdb/s390-tdep.h @@ -37,32 +37,33 @@ enum s390_vector_abi_kind /* The tdep structure. */ -struct gdbarch_tdep +struct s390_gdbarch_tdep : gdbarch_tdep { /* Target description. */ - const struct target_desc *tdesc; + const struct target_desc *tdesc = nullptr; /* ABI version. */ - enum s390_abi_kind abi; + enum s390_abi_kind abi {}; /* Vector ABI. */ - enum s390_vector_abi_kind vector_abi; + enum s390_vector_abi_kind vector_abi {}; /* Pseudo register numbers. */ - int gpr_full_regnum; - int pc_regnum; - int cc_regnum; - int v0_full_regnum; - - bool have_upper; - bool have_linux_v1; - bool have_linux_v2; - bool have_tdb; - bool have_vx; - bool have_gs; + int gpr_full_regnum = 0; + int pc_regnum = 0; + int cc_regnum = 0; + int v0_full_regnum = 0; + + bool have_upper = 0; + bool have_linux_v1 = 0; + bool have_linux_v2 = 0; + bool have_tdb = 0; + bool have_vx = 0; + bool have_gs = 0; /* Hook to record OS specific systemcall. */ - int (*s390_syscall_record) (struct regcache *regcache, LONGEST svc_number); + int (*s390_syscall_record) (struct regcache *regcache, LONGEST svc_number) + = nullptr; }; /* Decoding S/390 instructions. */ diff --git a/gdb/sh-linux-tdep.c b/gdb/sh-linux-tdep.c index 8315d46..9d4bebb 100644 --- a/gdb/sh-linux-tdep.c +++ b/gdb/sh-linux-tdep.c @@ -195,7 +195,7 @@ sh_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Remember regset characteristics. The sizes should match elf_gregset_t and elf_fpregset_t from Linux. */ diff --git a/gdb/sh-netbsd-tdep.c b/gdb/sh-netbsd-tdep.c index 0401eee..ddb2c7e 100644 --- a/gdb/sh-netbsd-tdep.c +++ b/gdb/sh-netbsd-tdep.c @@ -63,7 +63,7 @@ static void shnbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); nbsd_init_abi (info, gdbarch); tdep->core_gregmap = (struct sh_corefile_regmap *)regmap; diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index f78eb2d..4346e78 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1554,7 +1554,7 @@ sh_register_reggroup_p (struct gdbarch *gdbarch, int regnum, static struct type * sh_littlebyte_bigword_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->sh_littlebyte_bigword_type == NULL) tdep->sh_littlebyte_bigword_type @@ -2146,7 +2146,7 @@ sh_corefile_supply_regset (const struct regset *regset, int regnum, const void *regs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset ? tdep->core_gregmap : tdep->core_fpregmap); @@ -2172,7 +2172,7 @@ sh_corefile_collect_regset (const struct regset *regset, int regnum, void *regs, size_t len) { struct gdbarch *gdbarch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); const struct sh_corefile_regmap *regmap = (regset == &sh_corefile_gregset ? tdep->core_gregmap : tdep->core_fpregmap); @@ -2210,7 +2210,7 @@ sh_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sh_gdbarch_tdep *tdep = (sh_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->core_gregmap != NULL) cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, @@ -2237,7 +2237,6 @@ static struct gdbarch * sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; /* If there is already a candidate, use it. */ arches = gdbarch_list_lookup_by_info (arches, &info); @@ -2246,7 +2245,7 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + sh_gdbarch_tdep *tdep = new sh_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT); diff --git a/gdb/sh-tdep.h b/gdb/sh-tdep.h index 737b6dc..fce3f71 100644 --- a/gdb/sh-tdep.h +++ b/gdb/sh-tdep.h @@ -19,6 +19,8 @@ #ifndef SH_TDEP_H #define SH_TDEP_H +#include "gdbarch.h" + /* Contributed by Steve Chamberlain sac@cygnus.com. */ /* Registers for all SH variants. Used also by sh3-rom.c. */ @@ -89,20 +91,20 @@ struct sh_corefile_regmap unsigned int offset; }; -struct gdbarch_tdep +struct sh_gdbarch_tdep : gdbarch_tdep { /* Non-NULL when debugging from a core file. Provides the offset where each general-purpose register is stored inside the associated core file section. */ - struct sh_corefile_regmap *core_gregmap; - int sizeof_gregset; + struct sh_corefile_regmap *core_gregmap = nullptr; + int sizeof_gregset = 0; /* Non-NULL when debugging from a core file and when FP registers are available. Provides the offset where each FP register is stored inside the associated core file section. */ - struct sh_corefile_regmap *core_fpregmap; - int sizeof_fpregset; + struct sh_corefile_regmap *core_fpregmap = nullptr; + int sizeof_fpregset = 0; /* ISA-specific data types. */ - struct type *sh_littlebyte_bigword_type; + struct type *sh_littlebyte_bigword_type = nullptr; }; extern const struct regset sh_corefile_gregset; diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c index 4ad77e2..9c46919 100644 --- a/gdb/sparc-linux-tdep.c +++ b/gdb/sparc-linux-tdep.c @@ -253,7 +253,8 @@ sparc32_linux_collect_core_fpregset (const struct regset *regset, static void sparc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (arch); ULONGEST psr; regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc); @@ -420,7 +421,7 @@ static const struct regset sparc32_linux_fpregset = static void sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/sparc-netbsd-tdep.c b/gdb/sparc-netbsd-tdep.c index e34405c..e600447 100644 --- a/gdb/sparc-netbsd-tdep.c +++ b/gdb/sparc-netbsd-tdep.c @@ -295,7 +295,7 @@ static const struct regset sparc32nbsd_fpregset = void sparc32nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); nbsd_init_abi (info, gdbarch); diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c index f214449..94e8a12 100644 --- a/gdb/sparc-sol2-tdep.c +++ b/gdb/sparc-sol2-tdep.c @@ -196,7 +196,7 @@ static const struct frame_unwind sparc32_sol2_sigtramp_frame_unwind = static void sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->gregset = &sparc32_sol2_gregset; tdep->sizeof_gregset = 152; diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 7302929..31916b6 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -429,7 +429,7 @@ sparc32_register_name (struct gdbarch *gdbarch, int regnum) static struct type * sparc_psr_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->sparc_psr_type) { @@ -451,7 +451,7 @@ sparc_psr_type (struct gdbarch *gdbarch) static struct type * sparc_fsr_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->sparc_fsr_type) { @@ -992,7 +992,7 @@ CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct sparc_frame_cache *cache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned long insn; int offset = 0; int dest = -1; @@ -1684,8 +1684,9 @@ sparc_analyze_control_transfer (struct regcache *regcache, struct frame_info *frame = get_current_frame (); /* Trap instruction (TRAP). */ - return gdbarch_tdep (regcache->arch ())->step_trap (frame, - insn); + gdbarch *arch = regcache->arch (); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (arch); + return tdep->step_trap (frame, insn); } /* FIXME: Handle DONE and RETRY instructions. */ @@ -1735,7 +1736,7 @@ static std::vector sparc_software_single_step (struct regcache *regcache) { struct gdbarch *arch = regcache->arch (); - struct gdbarch_tdep *tdep = gdbarch_tdep (arch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (arch); CORE_ADDR npc, nnpc; CORE_ADDR pc, orig_npc; @@ -1764,7 +1765,8 @@ sparc_software_single_step (struct regcache *regcache) static void sparc_write_pc (struct regcache *regcache, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (arch); regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc); regcache_cooked_write_unsigned (regcache, tdep->npc_regnum, pc + 4); @@ -1779,7 +1781,7 @@ sparc_iterate_over_regset_sections (struct gdbarch *gdbarch, void *cb_data, const struct regcache *regcache) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, tdep->gregset, NULL, cb_data); @@ -1814,7 +1816,6 @@ validate_tdesc_registers (const struct target_desc *tdesc, static struct gdbarch * sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; const struct target_desc *tdesc = info.target_desc; struct gdbarch *gdbarch; int valid_p = 1; @@ -1825,7 +1826,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; /* Allocate space for the new architecture. */ - tdep = XCNEW (struct gdbarch_tdep); + sparc_gdbarch_tdep *tdep = new sparc_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); tdep->pc_regnum = SPARC32_PC_REGNUM; diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h index c0cfd09..ceedb2c 100644 --- a/gdb/sparc-tdep.h +++ b/gdb/sparc-tdep.h @@ -20,6 +20,8 @@ #ifndef SPARC_TDEP_H #define SPARC_TDEP_H 1 +#include "gdbarch.h" + #define SPARC_CORE_REGISTERS \ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \ @@ -55,43 +57,44 @@ struct sparc_fpregmap /* SPARC architecture-specific information. */ -struct gdbarch_tdep +struct sparc_gdbarch_tdep : gdbarch_tdep { /* Register numbers for the PN and nPC registers. The definitions for (64-bit) UltraSPARC differ from the (32-bit) SPARC definitions. */ - int pc_regnum; - int npc_regnum; + int pc_regnum = 0; + int npc_regnum = 0; /* Register names specific for architecture (sparc32 vs. sparc64) */ - const char * const *fpu_register_names; - size_t fpu_registers_num; - const char * const *cp0_register_names; - size_t cp0_registers_num; + const char * const *fpu_register_names = nullptr; + size_t fpu_registers_num = 0; + const char * const *cp0_register_names = nullptr; + size_t cp0_registers_num = 0; /* Register sets. */ - const struct regset *gregset; - size_t sizeof_gregset; - const struct regset *fpregset; - size_t sizeof_fpregset; + const struct regset *gregset = nullptr; + size_t sizeof_gregset = 0; + const struct regset *fpregset = nullptr; + size_t sizeof_fpregset = 0; /* Offset of saved PC in jmp_buf. */ - int jb_pc_offset; + int jb_pc_offset = 0; /* Size of an Procedure Linkage Table (PLT) entry, 0 if we shouldn't treat the PLT special when doing prologue analysis. */ - size_t plt_entry_size; + size_t plt_entry_size = 0; /* Alternative location for trap return. Used for single-stepping. */ - CORE_ADDR (*step_trap) (struct frame_info *frame, unsigned long insn); + CORE_ADDR (*step_trap) (struct frame_info *frame, unsigned long insn) + = nullptr; /* ISA-specific data types. */ - struct type *sparc_psr_type; - struct type *sparc_fsr_type; - struct type *sparc64_ccr_type; - struct type *sparc64_pstate_type; - struct type *sparc64_fsr_type; - struct type *sparc64_fprs_type; + struct type *sparc_psr_type = nullptr; + struct type *sparc_fsr_type = nullptr; + struct type *sparc64_ccr_type = nullptr; + struct type *sparc64_pstate_type = nullptr; + struct type *sparc64_fsr_type = nullptr; + struct type *sparc64_fprs_type = nullptr; }; /* Register numbers of various important registers. */ diff --git a/gdb/sparc64-fbsd-tdep.c b/gdb/sparc64-fbsd-tdep.c index 6dad813..d52162a 100644 --- a/gdb/sparc64-fbsd-tdep.c +++ b/gdb/sparc64-fbsd-tdep.c @@ -222,7 +222,7 @@ static const struct regset sparc64fbsd_fpregset = static void sparc64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Generic FreeBSD support. */ fbsd_init_abi (info, gdbarch); diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index e63fa87..5b9cc90 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -261,7 +261,8 @@ sparc64_linux_collect_core_fpregset (const struct regset *regset, static void sparc64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { - struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ()); + gdbarch *arch = regcache->arch (); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (arch); ULONGEST state; regcache_cooked_write_unsigned (regcache, tdep->pc_regnum, pc); @@ -363,7 +364,7 @@ static const struct regset sparc64_linux_fpregset = static void sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/sparc64-netbsd-tdep.c b/gdb/sparc64-netbsd-tdep.c index 0438093..81e3763 100644 --- a/gdb/sparc64-netbsd-tdep.c +++ b/gdb/sparc64-netbsd-tdep.c @@ -248,7 +248,7 @@ static const struct regset sparc64nbsd_fpregset = static void sparc64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); nbsd_init_abi (info, gdbarch); diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c index 033779e..0931b23 100644 --- a/gdb/sparc64-obsd-tdep.c +++ b/gdb/sparc64-obsd-tdep.c @@ -423,7 +423,7 @@ static const struct regset sparc64obsd_fpregset = static void sparc64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->gregset = &sparc64obsd_gregset; tdep->sizeof_gregset = 288; diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c index 6aea8bd..6c1fe19 100644 --- a/gdb/sparc64-sol2-tdep.c +++ b/gdb/sparc64-sol2-tdep.c @@ -199,7 +199,7 @@ static const struct frame_unwind sparc64_sol2_sigtramp_frame_unwind = static void sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->gregset = &sparc64_sol2_gregset; tdep->sizeof_gregset = 304; diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index c0d3159..cb69830 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -648,7 +648,7 @@ sparc64_structure_or_union_p (const struct type *type) static struct type * sparc64_pstate_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->sparc64_pstate_type) { @@ -675,7 +675,7 @@ sparc64_pstate_type (struct gdbarch *gdbarch) static struct type * sparc64_ccr_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->sparc64_ccr_type == NULL) { @@ -700,7 +700,7 @@ sparc64_ccr_type (struct gdbarch *gdbarch) static struct type * sparc64_fsr_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->sparc64_fsr_type) { @@ -733,7 +733,7 @@ sparc64_fsr_type (struct gdbarch *gdbarch) static struct type * sparc64_fprs_type (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (!tdep->sparc64_fprs_type) { @@ -1806,7 +1806,7 @@ sparc64_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr) void sparc64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + sparc_gdbarch_tdep *tdep = (sparc_gdbarch_tdep *) gdbarch_tdep (gdbarch); tdep->pc_regnum = SPARC64_PC_REGNUM; tdep->npc_regnum = SPARC64_NPC_REGNUM; diff --git a/gdb/tic6x-linux-tdep.c b/gdb/tic6x-linux-tdep.c index 4e165ec..ff5fec8 100644 --- a/gdb/tic6x-linux-tdep.c +++ b/gdb/tic6x-linux-tdep.c @@ -45,7 +45,7 @@ static const gdb_byte tic6x_bkpt_bnop_le[] = { 0x22, 0xa1, 0x00, 0x00 }; static unsigned int tic6x_register_sigcontext_offset (unsigned int regnum, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + tic6x_gdbarch_tdep *tdep = (tic6x_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum == TIC6X_A4_REGNUM || regnum == TIC6X_A4_REGNUM + 2 || regnum == TIC6X_A4_REGNUM + 4) @@ -92,7 +92,7 @@ tic6x_linux_rt_sigreturn_init (const struct tramp_frame *self, + TIC6X_SIGINFO_SIZE + 4 + 4 /* uc_flags and *uc_link in struct ucontext. */ + TIC6X_STACK_T_SIZE); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + tic6x_gdbarch_tdep *tdep = (tic6x_gdbarch_tdep *) gdbarch_tdep (gdbarch); unsigned int reg_offset; unsigned int i; @@ -165,7 +165,7 @@ extern struct target_so_ops dsbt_so_ops; static void tic6x_uclinux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + tic6x_gdbarch_tdep *tdep = (tic6x_gdbarch_tdep *) gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch, 0); diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index afa034c..7b1d83b 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -325,7 +325,7 @@ tic6x_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) static const gdb_byte * tic6x_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + tic6x_gdbarch_tdep *tdep = (tic6x_gdbarch_tdep *) gdbarch_tdep (gdbarch); *size = kind; @@ -598,7 +598,8 @@ tic6x_get_next_pc (struct regcache *regcache, CORE_ADDR pc) if (inst == TIC6X_INST_SWE) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + tic6x_gdbarch_tdep *tdep + = (tic6x_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->syscall_next_pc != NULL) return tdep->syscall_next_pc (get_current_frame ()); @@ -1141,7 +1142,6 @@ static struct gdbarch * tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; tdesc_arch_data_up tdesc_data; const struct target_desc *tdesc = info.target_desc; int has_gp = 0; @@ -1216,7 +1216,8 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - tdep = gdbarch_tdep (arches->gdbarch); + tic6x_gdbarch_tdep *tdep + = (tic6x_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); if (has_gp != tdep->has_gp) continue; @@ -1225,7 +1226,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) return arches->gdbarch; } - tdep = XCNEW (struct gdbarch_tdep); + tic6x_gdbarch_tdep *tdep = new tic6x_gdbarch_tdep; tdep->has_gp = has_gp; gdbarch = gdbarch_alloc (&info, tdep); diff --git a/gdb/tic6x-tdep.h b/gdb/tic6x-tdep.h index 7d5587a..bb79a0d 100644 --- a/gdb/tic6x-tdep.h +++ b/gdb/tic6x-tdep.h @@ -20,6 +20,8 @@ #ifndef TIC6X_TDEP_H #define TIC6X_TDEP_H +#include "gdbarch.h" + enum { TIC6X_A4_REGNUM = 4, @@ -44,15 +46,15 @@ extern const gdb_byte tic6x_bkpt_illegal_opcode_be[]; extern const gdb_byte tic6x_bkpt_illegal_opcode_le[]; /* Target-dependent structure in gdbarch. */ -struct gdbarch_tdep +struct tic6x_gdbarch_tdep : gdbarch_tdep { /* Return the expected next PC if FRAME is stopped at a syscall instruction. */ - CORE_ADDR (*syscall_next_pc) (struct frame_info *frame); + CORE_ADDR (*syscall_next_pc) (struct frame_info *frame) = nullptr; - const gdb_byte *breakpoint; /* Breakpoint instruction. */ + const gdb_byte *breakpoint = nullptr; /* Breakpoint instruction. */ - int has_gp; /* Has general purpose registers A16 - A31 and B16 - B31. */ + int has_gp = 0; /* Has general purpose registers A16 - A31 and B16 - B31. */ }; #endif /* TIC6X_TDEP_H */ diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index f829f4d..70f6d42 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -264,15 +264,15 @@ enum v850_abi /* Architecture specific data. */ -struct gdbarch_tdep +struct v850_gdbarch_tdep : gdbarch_tdep { /* Fields from the ELF header. */ - int e_flags; - int e_machine; + int e_flags = 0; + int e_machine = 0; /* Which ABI are we using? */ - enum v850_abi abi; - int eight_byte_align; + enum v850_abi abi {}; + int eight_byte_align = 0; }; struct v850_frame_cache @@ -510,8 +510,9 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) { int i; struct type *fld_type, *tgt_type; + v850_gdbarch_tdep *tdep = (v850_gdbarch_tdep *) gdbarch_tdep (gdbarch); - if (gdbarch_tdep (gdbarch)->abi == V850_ABI_RH850) + if (tdep->abi == V850_ABI_RH850) { if (v850_type_is_scalar (type) && TYPE_LENGTH(type) <= 8) return 0; @@ -1021,8 +1022,9 @@ v850_push_dummy_call (struct gdbarch *gdbarch, int argnum; int arg_space = 0; int stack_offset; + v850_gdbarch_tdep *tdep = (v850_gdbarch_tdep *) gdbarch_tdep (gdbarch); - if (gdbarch_tdep (gdbarch)->abi == V850_ABI_RH850) + if (tdep->abi == V850_ABI_RH850) stack_offset = 0; else { @@ -1054,7 +1056,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, gdb_byte valbuf[v850_reg_size]; if (!v850_type_is_scalar (value_type (*args)) - && gdbarch_tdep (gdbarch)->abi == V850_ABI_GCC + && tdep->abi == V850_ABI_GCC && TYPE_LENGTH (value_type (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS) { store_unsigned_integer (valbuf, 4, byte_order, @@ -1068,7 +1070,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch, val = (gdb_byte *) value_contents (*args).data (); } - if (gdbarch_tdep (gdbarch)->eight_byte_align + if (tdep->eight_byte_align && v850_eight_byte_align_p (value_type (*args))) { if (argreg <= E_ARGLAST_REGNUM && (argreg & 1)) @@ -1348,7 +1350,6 @@ static struct gdbarch * v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; int e_flags, e_machine; /* Extract the elf_flags if available. */ @@ -1371,13 +1372,16 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) arches != NULL; arches = gdbarch_list_lookup_by_info (arches->next, &info)) { - if (gdbarch_tdep (arches->gdbarch)->e_flags != e_flags - || gdbarch_tdep (arches->gdbarch)->e_machine != e_machine) + v850_gdbarch_tdep *tdep + = (v850_gdbarch_tdep *) gdbarch_tdep (arches->gdbarch); + + if (tdep->e_flags != e_flags || tdep->e_machine != e_machine) continue; return arches->gdbarch; } - tdep = XCNEW (struct gdbarch_tdep); + + v850_gdbarch_tdep *tdep = new v850_gdbarch_tdep; tdep->e_flags = e_flags; tdep->e_machine = e_machine; diff --git a/gdb/xtensa-config.c b/gdb/xtensa-config.c index 2c21c78..57a9ff0 100644 --- a/gdb/xtensa-config.c +++ b/gdb/xtensa-config.c @@ -62,7 +62,7 @@ const xtensa_mask_t xtensa_mask15 = { 1, xtensa_submask15 }; /* Register map. */ -xtensa_register_t rmap[] = +static xtensa_register_t rmap[] = { /* idx ofs bi sz al targno flags cp typ group name */ XTREG( 0, 0,32, 4, 4,0x0020,0x0006,-2, 9,0x0100,pc, 0,0,0,0,0,0) @@ -213,9 +213,4 @@ xtensa_register_t rmap[] = XTREG_END }; - - -#ifdef XTENSA_CONFIG_INSTANTIATE -XTENSA_CONFIG_INSTANTIATE(rmap,0) -#endif - +xtensa_gdbarch_tdep xtensa_tdep (rmap); diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c index c9e2519..b24ebc5 100644 --- a/gdb/xtensa-linux-tdep.c +++ b/gdb/xtensa-linux-tdep.c @@ -99,7 +99,7 @@ xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch, static void xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (tdep->num_nopriv_regs < tdep->num_regs) { diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 42bff4c..f09d233 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -86,13 +86,13 @@ static unsigned int xtensa_debug_level = 0; #define TX_PS 0x20 /* ABI-independent macros. */ -#define ARG_NOF(gdbarch) \ - (gdbarch_tdep (gdbarch)->call_abi \ +#define ARG_NOF(tdep) \ + (tdep->call_abi \ == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS)) -#define ARG_1ST(gdbarch) \ - (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only \ - ? (gdbarch_tdep (gdbarch)->a0_base + C0_ARGS) \ - : (gdbarch_tdep (gdbarch)->a0_base + 6)) +#define ARG_1ST(tdep) \ + (tdep->call_abi == CallAbiCall0Only \ + ? (tdep->a0_base + C0_ARGS) \ + : (tdep->a0_base + 6)) /* XTENSA_IS_ENTRY tests whether the first byte of an instruction indicates that the instruction is an ENTRY instruction. */ @@ -116,8 +116,10 @@ static unsigned int xtensa_debug_level = 0; static int windowing_enabled (struct gdbarch *gdbarch, unsigned int ps) { + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + /* If we know CALL0 ABI is set explicitly, say it is Call0. */ - if (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only) + if (tdep->call_abi == CallAbiCall0Only) return 0; return ((ps & PS_EXC) == 0 && (ps & PS_WOE) != 0); @@ -128,7 +130,7 @@ windowing_enabled (struct gdbarch *gdbarch, unsigned int ps) static int arreg_number (struct gdbarch *gdbarch, int a_regnum, ULONGEST wb) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); int arreg; arreg = a_regnum - tdep->a0_base; @@ -143,7 +145,7 @@ arreg_number (struct gdbarch *gdbarch, int a_regnum, ULONGEST wb) static int areg_number (struct gdbarch *gdbarch, int ar_regnum, unsigned int wb) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); int areg; areg = ar_regnum - tdep->ar_base; @@ -224,10 +226,10 @@ static int xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name) { int i; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++) - - if (strcasecmp (gdbarch_tdep (gdbarch)->regmap[i].name, name) == 0) + if (strcasecmp (tdep->regmap[i].name, name) == 0) return i; return -1; @@ -237,9 +239,11 @@ xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name) static const char * xtensa_register_name (struct gdbarch *gdbarch, int regnum) { + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + /* Return the name stored in the register map. */ if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) - return gdbarch_tdep (gdbarch)->regmap[regnum].name; + return tdep->regmap[regnum].name; internal_error (__FILE__, __LINE__, _("invalid register %d"), regnum); return 0; @@ -250,7 +254,7 @@ xtensa_register_name (struct gdbarch *gdbarch, int regnum) static struct type * xtensa_register_type (struct gdbarch *gdbarch, int regnum) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Return signed integer for ARx and Ax registers. */ if ((regnum >= tdep->ar_base @@ -335,12 +339,13 @@ static int xtensa_reg_to_regnum (struct gdbarch *gdbarch, int regnum) { int i; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (regnum >= 0 && regnum < 16) - return gdbarch_tdep (gdbarch)->a0_base + regnum; + return tdep->a0_base + regnum; for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++) - if (regnum == gdbarch_tdep (gdbarch)->regmap[i].target_number) + if (regnum == tdep->regmap[i].target_number) return i; return -1; @@ -537,16 +542,17 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch, { DEBUGTRACE ("xtensa_pseudo_register_read (... regnum = %d (%s) ...)\n", regnum, xtensa_register_name (gdbarch, regnum)); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Read aliases a0..a15, if this is a Windowed ABI. */ - if (gdbarch_tdep (gdbarch)->isa_use_windowed_registers - && (regnum >= gdbarch_tdep (gdbarch)->a0_base) - && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15)) + if (tdep->isa_use_windowed_registers + && (regnum >= tdep->a0_base) + && (regnum <= tdep->a0_base + 15)) { ULONGEST value; enum register_status status; - status = regcache->raw_read (gdbarch_tdep (gdbarch)->wb_regnum, + status = regcache->raw_read (tdep->wb_regnum, &value); if (status != REG_VALID) return status; @@ -560,8 +566,8 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch, /* We have to find out how to deal with priveleged registers. Let's treat them as pseudo-registers, but we cannot read/write them. */ - else if (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only - || regnum < gdbarch_tdep (gdbarch)->a0_base) + else if (tdep->call_abi == CallAbiCall0Only + || regnum < tdep->a0_base) { buffer[0] = (gdb_byte)0; buffer[1] = (gdb_byte)0; @@ -572,9 +578,9 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch, /* Pseudo registers. */ else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) { - xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum]; + xtensa_register_t *reg = &tdep->regmap[regnum]; xtensa_register_type_t type = reg->type; - int flags = gdbarch_tdep (gdbarch)->target_flags; + int flags = tdep->target_flags; /* We cannot read Unknown or Unmapped registers. */ if (type == xtRegisterTypeUnmapped || type == xtRegisterTypeUnknown) @@ -628,15 +634,16 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch, { DEBUGTRACE ("xtensa_pseudo_register_write (... regnum = %d (%s) ...)\n", regnum, xtensa_register_name (gdbarch, regnum)); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Renumber register, if aliases a0..a15 on Windowed ABI. */ - if (gdbarch_tdep (gdbarch)->isa_use_windowed_registers - && (regnum >= gdbarch_tdep (gdbarch)->a0_base) - && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15)) + if (tdep->isa_use_windowed_registers + && (regnum >= tdep->a0_base) + && (regnum <= tdep->a0_base + 15)) { ULONGEST value; regcache_raw_read_unsigned (regcache, - gdbarch_tdep (gdbarch)->wb_regnum, &value); + tdep->wb_regnum, &value); regnum = arreg_number (gdbarch, regnum, value); } @@ -648,16 +655,16 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch, /* We have to find out how to deal with priveleged registers. Let's treat them as pseudo-registers, but we cannot read/write them. */ - else if (regnum < gdbarch_tdep (gdbarch)->a0_base) + else if (regnum < tdep->a0_base) { return; } /* Pseudo registers. */ else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)) { - xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum]; + xtensa_register_t *reg = &tdep->regmap[regnum]; xtensa_register_type_t type = reg->type; - int flags = gdbarch_tdep (gdbarch)->target_flags; + int flags = tdep->target_flags; /* On most targets, we cannot write registers of type "Unknown" or "Unmapped". */ @@ -770,7 +777,8 @@ xtensa_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *group) { - xtensa_register_t* reg = &gdbarch_tdep (gdbarch)->regmap[regnum]; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + xtensa_register_t* reg = &tdep->regmap[regnum]; xtensa_register_type_t type = reg->type; xtensa_register_group_t rg = reg->group; int cp_number; @@ -823,6 +831,7 @@ xtensa_supply_gregset (const struct regset *regset, { const xtensa_elf_gregset_t *regs = (const xtensa_elf_gregset_t *) gregs; struct gdbarch *gdbarch = rc->arch (); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); int i; DEBUGTRACE ("xtensa_supply_gregset (..., regnum==%d, ...)\n", regnum); @@ -831,33 +840,33 @@ xtensa_supply_gregset (const struct regset *regset, rc->raw_supply (gdbarch_pc_regnum (gdbarch), (char *) ®s->pc); if (regnum == gdbarch_ps_regnum (gdbarch) || regnum == -1) rc->raw_supply (gdbarch_ps_regnum (gdbarch), (char *) ®s->ps); - if (regnum == gdbarch_tdep (gdbarch)->wb_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->wb_regnum, + if (regnum == tdep->wb_regnum || regnum == -1) + rc->raw_supply (tdep->wb_regnum, (char *) ®s->windowbase); - if (regnum == gdbarch_tdep (gdbarch)->ws_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->ws_regnum, + if (regnum == tdep->ws_regnum || regnum == -1) + rc->raw_supply (tdep->ws_regnum, (char *) ®s->windowstart); - if (regnum == gdbarch_tdep (gdbarch)->lbeg_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->lbeg_regnum, + if (regnum == tdep->lbeg_regnum || regnum == -1) + rc->raw_supply (tdep->lbeg_regnum, (char *) ®s->lbeg); - if (regnum == gdbarch_tdep (gdbarch)->lend_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->lend_regnum, + if (regnum == tdep->lend_regnum || regnum == -1) + rc->raw_supply (tdep->lend_regnum, (char *) ®s->lend); - if (regnum == gdbarch_tdep (gdbarch)->lcount_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->lcount_regnum, + if (regnum == tdep->lcount_regnum || regnum == -1) + rc->raw_supply (tdep->lcount_regnum, (char *) ®s->lcount); - if (regnum == gdbarch_tdep (gdbarch)->sar_regnum || regnum == -1) - rc->raw_supply (gdbarch_tdep (gdbarch)->sar_regnum, + if (regnum == tdep->sar_regnum || regnum == -1) + rc->raw_supply (tdep->sar_regnum, (char *) ®s->sar); - if (regnum >=gdbarch_tdep (gdbarch)->ar_base - && regnum < gdbarch_tdep (gdbarch)->ar_base - + gdbarch_tdep (gdbarch)->num_aregs) + if (regnum >=tdep->ar_base + && regnum < tdep->ar_base + + tdep->num_aregs) rc->raw_supply - (regnum, (char *) ®s->ar[regnum - gdbarch_tdep (gdbarch)->ar_base]); + (regnum, (char *) ®s->ar[regnum - tdep->ar_base]); else if (regnum == -1) { - for (i = 0; i < gdbarch_tdep (gdbarch)->num_aregs; ++i) - rc->raw_supply (gdbarch_tdep (gdbarch)->ar_base + i, + for (i = 0; i < tdep->num_aregs; ++i) + rc->raw_supply (tdep->ar_base + i, (char *) ®s->ar[i]); } } @@ -1051,12 +1060,13 @@ static struct frame_id xtensa_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame) { CORE_ADDR pc, fp; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* THIS-FRAME is a dummy frame. Return a frame ID of that frame. */ pc = get_frame_pc (this_frame); fp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + 1); + (this_frame, tdep->a0_base + 1); /* Make dummy frame ID unique by adding a constant. */ return frame_id_build (fp + SP_ALIGNMENT, pc); @@ -1105,7 +1115,8 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc) { #define RETURN_FP goto done - unsigned int fp_regnum = gdbarch_tdep (gdbarch)->a0_base + 1; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + unsigned int fp_regnum = tdep->a0_base + 1; CORE_ADDR start_addr; xtensa_isa isa; xtensa_insnbuf ins, slot; @@ -1182,7 +1193,7 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc) RETURN_FP; fp_regnum - = gdbarch_tdep (gdbarch)->a0_base + register_operand; + = tdep->a0_base + register_operand; RETURN_FP; } } @@ -1254,26 +1265,27 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache) if (windowed) { LONGEST op1; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Get WINDOWBASE, WINDOWSTART, and PS registers. */ wb = get_frame_register_unsigned (this_frame, - gdbarch_tdep (gdbarch)->wb_regnum); + tdep->wb_regnum); ws = get_frame_register_unsigned (this_frame, - gdbarch_tdep (gdbarch)->ws_regnum); + tdep->ws_regnum); if (safe_read_memory_integer (pc, 1, byte_order, &op1) && XTENSA_IS_ENTRY (gdbarch, op1)) { int callinc = CALLINC (ps); ra = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + callinc * 4); + (this_frame, tdep->a0_base + callinc * 4); /* ENTRY hasn't been executed yet, therefore callsize is still 0. */ cache->wd.callsize = 0; cache->wd.wb = wb; cache->wd.ws = ws; cache->prev_sp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + 1); + (this_frame, tdep->a0_base + 1); /* This only can be the outermost frame since we are just about to execute ENTRY. SP hasn't been set yet. @@ -1292,10 +1304,10 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache) { fp_regnum = xtensa_scan_prologue (gdbarch, pc); ra = get_frame_register_unsigned (this_frame, - gdbarch_tdep (gdbarch)->a0_base); + tdep->a0_base); cache->wd.callsize = WINSIZE (ra); cache->wd.wb = (wb - cache->wd.callsize / 4) - & (gdbarch_tdep (gdbarch)->num_aregs / 4 - 1); + & (tdep->num_aregs / 4 - 1); cache->wd.ws = ws & ~(1 << wb); cache->pc = get_frame_func (this_frame); @@ -1310,7 +1322,7 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache) /* Set A0...A3. */ sp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + 1) - 16; + (this_frame, tdep->a0_base + 1) - 16; for (i = 0; i < 4; i++, sp += 4) { @@ -1342,14 +1354,14 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache) /* Register window overflow already happened. We can read caller's SP from the proper spill location. */ sp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + 1); + (this_frame, tdep->a0_base + 1); cache->prev_sp = read_memory_integer (sp - 12, 4, byte_order); } else { /* Read caller's frame SP directly from the previous window. */ int regnum = arreg_number - (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1, + (gdbarch, tdep->a0_base + 1, cache->wd.wb); cache->prev_sp = xtensa_read_register (regnum); @@ -1415,6 +1427,7 @@ xtensa_frame_prev_register (struct frame_info *this_frame, struct xtensa_frame_cache *cache; ULONGEST saved_reg = 0; int done = 1; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); if (*this_cache == NULL) *this_cache = xtensa_frame_cache (this_frame, this_cache); @@ -1422,13 +1435,13 @@ xtensa_frame_prev_register (struct frame_info *this_frame, if (regnum ==gdbarch_pc_regnum (gdbarch)) saved_reg = cache->ra; - else if (regnum == gdbarch_tdep (gdbarch)->a0_base + 1) + else if (regnum == tdep->a0_base + 1) saved_reg = cache->prev_sp; else if (!cache->call0) { - if (regnum == gdbarch_tdep (gdbarch)->ws_regnum) + if (regnum == tdep->ws_regnum) saved_reg = cache->wd.ws; - else if (regnum == gdbarch_tdep (gdbarch)->wb_regnum) + else if (regnum == tdep->wb_regnum) saved_reg = cache->wd.wb; else if (regnum == gdbarch_ps_regnum (gdbarch)) saved_reg = cache->ps; @@ -1445,14 +1458,14 @@ xtensa_frame_prev_register (struct frame_info *this_frame, { /* Convert A-register numbers to AR-register numbers, if we deal with A-register. */ - if (regnum >= gdbarch_tdep (gdbarch)->a0_base - && regnum <= gdbarch_tdep (gdbarch)->a0_base + 15) + if (regnum >= tdep->a0_base + && regnum <= tdep->a0_base + 15) regnum = arreg_number (gdbarch, regnum, cache->wd.wb); /* Check, if we deal with AR-register saved on stack. */ - if (regnum >= gdbarch_tdep (gdbarch)->ar_base - && regnum <= (gdbarch_tdep (gdbarch)->ar_base - + gdbarch_tdep (gdbarch)->num_aregs)) + if (regnum >= tdep->ar_base + && regnum <= (tdep->ar_base + + tdep->num_aregs)) { int areg = areg_number (gdbarch, regnum, cache->wd.wb); @@ -1465,10 +1478,10 @@ xtensa_frame_prev_register (struct frame_info *this_frame, } else /* Call0 ABI. */ { - int reg = (regnum >= gdbarch_tdep (gdbarch)->ar_base - && regnum <= (gdbarch_tdep (gdbarch)->ar_base + int reg = (regnum >= tdep->ar_base + && regnum <= (tdep->ar_base + C0_NREGS)) - ? regnum - gdbarch_tdep (gdbarch)->ar_base : regnum; + ? regnum - tdep->ar_base : regnum; if (reg < C0_NREGS) { @@ -1543,7 +1556,8 @@ xtensa_extract_return_value (struct type *type, gdb_assert(len > 0); - if (gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only) + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->call_abi != CallAbiCall0Only) { /* First, we have to find the caller window in the register file. */ regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc); @@ -1558,14 +1572,14 @@ xtensa_extract_return_value (struct type *type, /* Get the register offset of the return register (A2) in the caller window. */ regcache_raw_read_unsigned - (regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb); + (regcache, tdep->wb_regnum, &wb); areg = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb); + tdep->a0_base + 2 + callsize, wb); } else { /* No windowing hardware - Call0 ABI. */ - areg = gdbarch_tdep (gdbarch)->a0_base + C0_ARGS; + areg = tdep->a0_base + C0_ARGS; } DEBUGINFO ("[xtensa_extract_return_value] areg %d len %d\n", areg, len); @@ -1598,10 +1612,11 @@ xtensa_store_return_value (struct type *type, DEBUGTRACE ("xtensa_store_return_value (...)\n"); - if (gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only) + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if (tdep->call_abi != CallAbiCall0Only) { regcache_raw_read_unsigned - (regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb); + (regcache, tdep->wb_regnum, &wb); regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc); callsize = extract_call_winsize (gdbarch, pc); @@ -1610,14 +1625,14 @@ xtensa_store_return_value (struct type *type, _("unimplemented for this length: %s"), pulongest (TYPE_LENGTH (type))); areg = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb); + tdep->a0_base + 2 + callsize, wb); DEBUGTRACE ("[xtensa_store_return_value] callsize %d wb %d\n", callsize, (int) wb); } else { - areg = gdbarch_tdep (gdbarch)->a0_base + C0_ARGS; + areg = tdep->a0_base + C0_ARGS; } if (len < 4 && gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) @@ -1681,6 +1696,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR struct_addr) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); int size, onstack_size; gdb_byte *buf = (gdb_byte *) alloca (16); CORE_ADDR ra, ps; @@ -1793,7 +1809,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, size = (size + info->align - 1) & ~(info->align - 1); onstack_size = (onstack_size + info->align - 1) & ~(info->align - 1); - if (size + info->length > REGISTER_SIZE * ARG_NOF (gdbarch)) + if (size + info->length > REGISTER_SIZE * ARG_NOF (tdep)) { info->onstack = 1; info->u.offset = onstack_size; @@ -1802,7 +1818,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, else { info->onstack = 0; - info->u.regno = ARG_1ST (gdbarch) + size / REGISTER_SIZE; + info->u.regno = ARG_1ST (tdep) + size / REGISTER_SIZE; } size += info->length; } @@ -1811,7 +1827,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, sp = align_down (sp - onstack_size, SP_ALIGNMENT); /* Simulate MOVSP, if Windowed ABI. */ - if ((gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only) + if ((tdep->call_abi != CallAbiCall0Only) && (sp != osp)) { read_memory (osp - 16, buf, 16); @@ -1823,7 +1839,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, if (return_method == return_method_struct) { store_unsigned_integer (buf, REGISTER_SIZE, byte_order, struct_addr); - regcache->cooked_write (ARG_1ST (gdbarch), buf); + regcache->cooked_write (ARG_1ST (tdep), buf); } for (int i = 0; i < nargs; i++) @@ -1887,7 +1903,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, The return address for the current function (in A0) is saved in the dummy frame, so we can safely overwrite A0 here. */ - if (gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only) + if (tdep->call_abi != CallAbiCall0Only) { ULONGEST val; @@ -1895,7 +1911,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, regcache_raw_read_unsigned (regcache, gdbarch_ps_regnum (gdbarch), &val); ps = (unsigned long) val & ~0x00030000; regcache_cooked_write_unsigned - (regcache, gdbarch_tdep (gdbarch)->a0_base + 4, ra); + (regcache, tdep->a0_base + 4, ra); regcache_cooked_write_unsigned (regcache, gdbarch_ps_regnum (gdbarch), ps | 0x00010000); @@ -1905,21 +1921,21 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, to modify WINDOWSTART register to make it look like there is only one register window corresponding to WINDOWEBASE. */ - regcache->raw_read (gdbarch_tdep (gdbarch)->wb_regnum, buf); + regcache->raw_read (tdep->wb_regnum, buf); regcache_cooked_write_unsigned - (regcache, gdbarch_tdep (gdbarch)->ws_regnum, + (regcache, tdep->ws_regnum, 1 << extract_unsigned_integer (buf, 4, byte_order)); } else { /* Simulate CALL0: write RA into A0 register. */ regcache_cooked_write_unsigned - (regcache, gdbarch_tdep (gdbarch)->a0_base, bp_addr); + (regcache, tdep->a0_base, bp_addr); } /* Set new stack pointer and return it. */ regcache_cooked_write_unsigned (regcache, - gdbarch_tdep (gdbarch)->a0_base + 1, sp); + tdep->a0_base + 1, sp); /* Make dummy frame ID unique by adding a constant. */ return sp + SP_ALIGNMENT; } @@ -1929,7 +1945,9 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, static int xtensa_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) { - if (gdbarch_tdep (gdbarch)->isa_use_density_instructions) + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + + if (tdep->isa_use_density_instructions) return 2; else return 4; @@ -2174,6 +2192,7 @@ call0_track_op (struct gdbarch *gdbarch, xtensa_c0reg_t dst[], xtensa_c0reg_t sr { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned litbase, litaddr, litval; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); switch (opclass) { @@ -2264,9 +2283,9 @@ call0_track_op (struct gdbarch *gdbarch, xtensa_c0reg_t dst[], xtensa_c0reg_t sr /* 2 operands: dst, literal offset. */ gdb_assert (nods == 2); /* litbase = xtensa_get_litbase (pc); can be also used. */ - litbase = (gdbarch_tdep (gdbarch)->litbase_regnum == -1) + litbase = (tdep->litbase_regnum == -1) ? 0 : xtensa_read_register - (gdbarch_tdep (gdbarch)->litbase_regnum); + (tdep->litbase_regnum); litaddr = litbase & 1 ? (litbase & ~1) + (signed)odv[1] : (pc + 3 + (signed)odv[1]) & ~3; @@ -2548,9 +2567,10 @@ call0_frame_cache (struct frame_info *this_frame, CORE_ADDR body_pc=UINT_MAX; /* PC, where prologue analysis stopped. */ CORE_ADDR sp, fp, ra; int fp_regnum = C0_SP, c0_hasfp = 0, c0_frmsz = 0, prev_sp = 0, to_stk; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); sp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + 1); + (this_frame, tdep->a0_base + 1); fp = sp; /* Assume FP == SP until proven otherwise. */ /* Find the beginning of the prologue of the function containing the PC @@ -2584,12 +2604,12 @@ call0_frame_cache (struct frame_info *this_frame, was derived from SP. Otherwise, it would be C0_FP. */ fp_regnum = c0_hasfp ? C0_FP : C0_SP; c0_frmsz = - cache->c0.c0_rt[fp_regnum].fr_ofs; - fp_regnum += gdbarch_tdep (gdbarch)->a0_base; + fp_regnum += tdep->a0_base; } else /* No data from the prologue analysis. */ { c0_hasfp = 0; - fp_regnum = gdbarch_tdep (gdbarch)->a0_base + C0_SP; + fp_regnum = tdep->a0_base + C0_SP; c0_frmsz = 0; start_pc = pc; } @@ -2613,7 +2633,7 @@ call0_frame_cache (struct frame_info *this_frame, if (cache->c0.c0_sp_ofs == C0_NOSTK) /* Saved unaligned value of SP is kept in a register. */ unaligned_sp = get_frame_register_unsigned - (this_frame, gdbarch_tdep (gdbarch)->a0_base + cache->c0.c0_old_sp); + (this_frame, tdep->a0_base + cache->c0.c0_old_sp); else /* Get the value from stack. */ unaligned_sp = (CORE_ADDR) @@ -2673,7 +2693,7 @@ call0_frame_cache (struct frame_info *this_frame, { ra = get_frame_register_unsigned (this_frame, - gdbarch_tdep (gdbarch)->a0_base + cache->c0.c0_rt[i].fr_reg); + tdep->a0_base + cache->c0.c0_rt[i].fr_reg); } else ra = 0; } @@ -2700,8 +2720,9 @@ static int a11_was_saved; static void execute_l32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb) { - int atreg = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base + at, wb); - int asreg = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base + as, wb); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int atreg = arreg_number (gdbarch, tdep->a0_base + at, wb); + int asreg = arreg_number (gdbarch, tdep->a0_base + as, wb); CORE_ADDR addr = xtensa_read_register (asreg) + offset; unsigned int spilled_value = read_memory_unsigned_integer (addr, 4, gdbarch_byte_order (gdbarch)); @@ -2729,8 +2750,9 @@ execute_l32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb) static void execute_s32e (struct gdbarch *gdbarch, int at, int as, int offset, CORE_ADDR wb) { - int atreg = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base + at, wb); - int asreg = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base + as, wb); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int atreg = arreg_number (gdbarch, tdep->a0_base + at, wb); + int asreg = arreg_number (gdbarch, tdep->a0_base + as, wb); CORE_ADDR addr = xtensa_read_register (asreg) + offset; ULONGEST spilled_value = xtensa_read_register (atreg); @@ -2762,6 +2784,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb) xtensa_opcode opc; int insn_num = 0; void (*func) (struct gdbarch *, int, int, int, CORE_ADDR); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); uint32_t at, as, offset; @@ -2827,7 +2850,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb) if (a0_was_saved) { int arreg = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base, + tdep->a0_base, wb); xtensa_write_register (arreg, a0_saved); } @@ -2840,7 +2863,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb) if (a11_was_saved) { int arreg = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base + 11, + tdep->a0_base + 11, wb); xtensa_write_register (arreg, a11_saved); } @@ -2848,7 +2871,7 @@ execute_code (struct gdbarch *gdbarch, CORE_ADDR current_pc, CORE_ADDR wb) else if (a7_was_saved) { int arreg = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base + 7, + tdep->a0_base + 7, wb); xtensa_write_register (arreg, a7_saved); } @@ -2892,12 +2915,13 @@ xtensa_window_interrupt_frame_cache (struct frame_info *this_frame, CORE_ADDR ps, wb, ws, ra; int epc1_regnum, i, regnum; xtensa_exception_handler_t eh_type; + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); /* Read PS, WB, and WS from the hardware. Note that PS register must be present, if Windowed ABI is supported. */ ps = xtensa_read_register (gdbarch_ps_regnum (gdbarch)); - wb = xtensa_read_register (gdbarch_tdep (gdbarch)->wb_regnum); - ws = xtensa_read_register (gdbarch_tdep (gdbarch)->ws_regnum); + wb = xtensa_read_register (tdep->wb_regnum); + ws = xtensa_read_register (tdep->ws_regnum); /* Execute all the remaining instructions from Window Interrupt Handler by simulating them on the remote protocol level. On return, set the @@ -2920,7 +2944,7 @@ Unable to decode Xtensa Window Interrupt Handler's code.")); cache->wd.ws = ws | (1 << wb); cache->wd.wb = (ps & 0xf00) >> 8; /* Set WB to OWB. */ - regnum = arreg_number (gdbarch, gdbarch_tdep (gdbarch)->a0_base, + regnum = arreg_number (gdbarch, tdep->a0_base, cache->wd.wb); ra = xtensa_read_register (regnum); cache->wd.callsize = WINSIZE (ra); @@ -2928,7 +2952,7 @@ Unable to decode Xtensa Window Interrupt Handler's code.")); /* Set regnum to a frame pointer of the frame being cached. */ regnum = xtensa_scan_prologue (gdbarch, pc); regnum = arreg_number (gdbarch, - gdbarch_tdep (gdbarch)->a0_base + regnum, + tdep->a0_base + regnum, cache->wd.wb); cache->base = get_frame_register_unsigned (this_frame, regnum); @@ -3005,7 +3029,8 @@ xtensa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) CORE_ADDR end_func; - if ((gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only) + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); + if ((tdep->call_abi == CallAbiCall0Only) && call0_ret (start_pc, prologue_sal.end)) return start_pc; @@ -3026,7 +3051,7 @@ xtensa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) static void xtensa_verify_config (struct gdbarch *gdbarch) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + xtensa_gdbarch_tdep *tdep = (xtensa_gdbarch_tdep *) gdbarch_tdep (gdbarch); string_file log; /* Verify that we got a reasonable number of AREGS. */ @@ -3064,7 +3089,7 @@ xtensa_verify_config (struct gdbarch *gdbarch) /* Derive specific register numbers from the array of registers. */ static void -xtensa_derive_tdep (struct gdbarch_tdep *tdep) +xtensa_derive_tdep (xtensa_gdbarch_tdep *tdep) { xtensa_register_t* rmap; int n, max_size = 4; @@ -3139,12 +3164,11 @@ xtensa_derive_tdep (struct gdbarch_tdep *tdep) /* Module "constructor" function. */ -extern struct gdbarch_tdep xtensa_tdep; +extern xtensa_gdbarch_tdep xtensa_tdep; static struct gdbarch * xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; struct gdbarch *gdbarch; DEBUGTRACE ("gdbarch_init()\n"); @@ -3155,7 +3179,7 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* We have to set the byte order before we call gdbarch_alloc. */ info.byte_order = XCHAL_HAVE_BE ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; - tdep = &xtensa_tdep; + xtensa_gdbarch_tdep *tdep = &xtensa_tdep; gdbarch = gdbarch_alloc (&info, tdep); xtensa_derive_tdep (tdep); diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h index 55a2ed4..64e4da6 100644 --- a/gdb/xtensa-tdep.h +++ b/gdb/xtensa-tdep.h @@ -21,6 +21,8 @@ #define XTENSA_TDEP_H #include "arch/xtensa.h" +#include "gdbarch.h" +#include "xtensa-config.h" /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION whenever the "tdep" structure changes in an incompatible way. */ @@ -155,137 +157,91 @@ struct ctype_cache struct type *virtual_type; }; +#ifndef XCHAL_NUM_CONTEXTS +# define XCHAL_NUM_CONTEXTS 0 +#endif + +#ifndef XCHAL_HAVE_EXCEPTIONS +# define XCHAL_HAVE_EXCEPTIONS 1 +#endif + /* Xtensa-specific target dependencies. */ -struct gdbarch_tdep +struct xtensa_gdbarch_tdep : gdbarch_tdep { - unsigned int target_flags; + xtensa_gdbarch_tdep (xtensa_register_t *regmap) + : regmap (regmap) + {} + + unsigned int target_flags = 0; /* Spill location for TIE register files under ocd. */ - unsigned int spill_location; - unsigned int spill_size; + unsigned int spill_location = (unsigned int) -1; + unsigned int spill_size = 0; - char *unused; /* Placeholder for compatibility. */ - call_abi_t call_abi; /* Calling convention. */ + char *unused = nullptr; /* Placeholder for compatibility. */ + + /* Calling convention. */ + call_abi_t call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0 + ? CallAbiCall0Only : CallAbiDefault); /* CPU configuration. */ - unsigned int debug_interrupt_level; + unsigned int debug_interrupt_level = XCHAL_DEBUGLEVEL; - unsigned int icache_line_bytes; - unsigned int dcache_line_bytes; - unsigned int dcache_writeback; + unsigned int icache_line_bytes = XCHAL_ICACHE_LINESIZE; + unsigned int dcache_line_bytes = XCHAL_DCACHE_LINESIZE; + unsigned int dcache_writeback = XCHAL_DCACHE_IS_WRITEBACK; - unsigned int isa_use_windowed_registers; - unsigned int isa_use_density_instructions; - unsigned int isa_use_exceptions; - unsigned int isa_use_ext_l32r; - unsigned int isa_max_insn_size; /* Maximum instruction length. */ - unsigned int debug_num_ibreaks; /* Number of IBREAKs. */ - unsigned int debug_num_dbreaks; + unsigned int isa_use_windowed_registers = XSHAL_ABI != XTHAL_ABI_CALL0; + unsigned int isa_use_density_instructions = XCHAL_HAVE_DENSITY; + unsigned int isa_use_exceptions = XCHAL_HAVE_EXCEPTIONS; + unsigned int isa_use_ext_l32r = XSHAL_USE_ABSOLUTE_LITERALS; + unsigned int isa_max_insn_size = XCHAL_MAX_INSTRUCTION_SIZE; /* Maximum instruction length. */ + unsigned int debug_num_ibreaks = XCHAL_NUM_IBREAK; /* Number of IBREAKs. */ + unsigned int debug_num_dbreaks = XCHAL_NUM_DBREAK; /* Register map. */ - xtensa_register_t* regmap; - - unsigned int num_regs; /* Number of registers in register map. */ - unsigned int num_nopriv_regs; /* Number of non-privileged registers. */ - unsigned int num_pseudo_regs; /* Number of pseudo registers. */ - unsigned int num_aregs; /* Size of register file. */ - unsigned int num_contexts; - - int ar_base; /* Register number for AR0. */ - int a0_base; /* Register number for A0 (pseudo). */ - int wb_regnum; /* Register number for WB. */ - int ws_regnum; /* Register number for WS. */ - int pc_regnum; /* Register number for PC. */ - int ps_regnum; /* Register number for PS. */ - int lbeg_regnum; /* Register numbers for count regs. */ - int lend_regnum; - int lcount_regnum; - int sar_regnum; /* Register number of SAR. */ - int litbase_regnum; /* Register number of LITBASE. */ - int threadptr_regnum; /* Register number of THREADPTR. */ - - int interrupt_regnum; /* Register number for interrupt. */ - int interrupt2_regnum; /* Register number for interrupt2. */ - int cpenable_regnum; /* Register number for cpenable. */ - int debugcause_regnum; /* Register number for debugcause. */ - int exccause_regnum; /* Register number for exccause. */ - int excvaddr_regnum; /* Register number for excvaddr. */ - - int max_register_raw_size; - int max_register_virtual_size; - unsigned long *fp_layout; /* Layout of custom/TIE regs in 'FP' area. */ - unsigned int fp_layout_bytes; /* Size of layout information (in bytes). */ - unsigned long *gregmap; + xtensa_register_t *regmap; + + unsigned int num_regs = 0; /* Number of registers in register map. */ + unsigned int num_nopriv_regs = 0; /* Number of non-privileged registers. */ + unsigned int num_pseudo_regs = 0; /* Number of pseudo registers. */ + unsigned int num_aregs = XCHAL_NUM_AREGS; /* Size of register file. */ + unsigned int num_contexts = XCHAL_NUM_CONTEXTS; + + int ar_base = -1; /* Register number for AR0. */ + int a0_base = -1; /* Register number for A0 (pseudo). */ + int wb_regnum = -1; /* Register number for WB. */ + int ws_regnum = -1; /* Register number for WS. */ + int pc_regnum = -1; /* Register number for PC. */ + int ps_regnum = -1; /* Register number for PS. */ + int lbeg_regnum = -1; /* Register numbers for count regs. */ + int lend_regnum = -1; + int lcount_regnum = -1; + int sar_regnum = -1; /* Register number of SAR. */ + int litbase_regnum = -1; /* Register number of LITBASE. */ + int threadptr_regnum = -1; /* Register number of THREADPTR. */ + + int interrupt_regnum = -1; /* Register number for interrupt. */ + int interrupt2_regnum = -1; /* Register number for interrupt2. */ + int cpenable_regnum = -1; /* Register number for cpenable. */ + int debugcause_regnum = -1; /* Register number for debugcause. */ + int exccause_regnum = -1; /* Register number for exccause. */ + int excvaddr_regnum = -1; /* Register number for excvaddr. */ + + int max_register_raw_size = 0; + int max_register_virtual_size = 0; + unsigned long *fp_layout = nullptr; /* Layout of custom/TIE regs in 'FP' area. */ + unsigned int fp_layout_bytes = 0; /* Size of layout information (in bytes). */ + unsigned long *gregmap = nullptr; /* Cached register types. */ - struct ctype_cache *type_entries; + struct ctype_cache *type_entries = nullptr; }; -/* Macro to instantiate a gdbarch_tdep structure. */ - -#define XTENSA_GDBARCH_TDEP_INSTANTIATE(rmap,spillsz) \ - { \ - 0, /* target_flags */ \ - (unsigned) -1, /* spill_location */ \ - (spillsz), /* spill_size */ \ - 0, /* unused */ \ - (XSHAL_ABI == XTHAL_ABI_CALL0 \ - ? CallAbiCall0Only \ - : CallAbiDefault), /* call_abi */ \ - XCHAL_DEBUGLEVEL, /* debug_interrupt_level */ \ - XCHAL_ICACHE_LINESIZE, /* icache_line_bytes */ \ - XCHAL_DCACHE_LINESIZE, /* dcache_line_bytes */ \ - XCHAL_DCACHE_IS_WRITEBACK, /* dcache_writeback */ \ - (XSHAL_ABI != XTHAL_ABI_CALL0), /* isa_use_windowed_registers */ \ - XCHAL_HAVE_DENSITY, /* isa_use_density_instructions */ \ - XCHAL_HAVE_EXCEPTIONS, /* isa_use_exceptions */ \ - XSHAL_USE_ABSOLUTE_LITERALS, /* isa_use_ext_l32r */ \ - XCHAL_MAX_INSTRUCTION_SIZE, /* isa_max_insn_size */ \ - XCHAL_NUM_IBREAK, /* debug_num_ibreaks */ \ - XCHAL_NUM_DBREAK, /* debug_num_dbreaks */ \ - rmap, /* regmap */ \ - 0, /* num_regs */ \ - 0, /* num_nopriv_regs */ \ - 0, /* num_pseudo_regs */ \ - XCHAL_NUM_AREGS, /* num_aregs */ \ - XCHAL_NUM_CONTEXTS, /* num_contexts */ \ - -1, /* ar_base */ \ - -1, /* a0_base */ \ - -1, /* wb_regnum */ \ - -1, /* ws_regnum */ \ - -1, /* pc_regnum */ \ - -1, /* ps_regnum */ \ - -1, /* lbeg_regnum */ \ - -1, /* lend_regnum */ \ - -1, /* lcount_regnum */ \ - -1, /* sar_regnum */ \ - -1, /* litbase_regnum */ \ - -1, /* interrupt_regnum */ \ - -1, /* interrupt2_regnum */ \ - -1, /* cpenable_regnum */ \ - -1, /* debugcause_regnum */ \ - -1, /* exccause_regnum */ \ - -1, /* excvaddr_regnum */ \ - 0, /* max_register_raw_size */ \ - 0, /* max_register_virtual_size */ \ - 0, /* fp_layout */ \ - 0, /* fp_layout_bytes */ \ - 0, /* gregmap */ \ - } -#define XTENSA_CONFIG_INSTANTIATE(rmap,spill_size) \ - struct gdbarch_tdep xtensa_tdep = \ - XTENSA_GDBARCH_TDEP_INSTANTIATE(rmap,spill_size); - -#ifndef XCHAL_NUM_CONTEXTS -#define XCHAL_NUM_CONTEXTS 0 -#endif -#ifndef XCHAL_HAVE_EXCEPTIONS -#define XCHAL_HAVE_EXCEPTIONS 1 -#endif #define WB_SHIFT 2 /* We assign fixed numbers to the registers of the "current" window diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index 7b9a7e2..9d453cd 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -54,19 +54,21 @@ __gdb_break_handler: next frame - frame of caller, which has called current function */ -struct gdbarch_tdep +struct z80_gdbarch_tdep : gdbarch_tdep { /* Number of bytes used for address: 2 bytes for all Z80 family 3 bytes for eZ80 CPUs operating in ADL mode */ - int addr_length; + int addr_length = 0; /* Type for void. */ - struct type *void_type; + struct type *void_type = nullptr; + /* Type for a function returning void. */ - struct type *func_void_type; + struct type *func_void_type = nullptr; + /* Type for a pointer to a function. Used for the type of PC. */ - struct type *pc_type; + struct type *pc_type = nullptr; }; /* At any time stack frame contains following parts: @@ -305,7 +307,8 @@ z80_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, struct z80_unwind_cache *info) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int addr_len = gdbarch_tdep (gdbarch)->addr_length; + z80_gdbarch_tdep *tdep = (z80_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int addr_len = tdep->addr_length; gdb_byte prologue[32]; /* max prologue is 24 bytes: __interrupt with local array */ int pos = 0; int len; @@ -560,7 +563,8 @@ z80_frame_unwind_cache (struct frame_info *this_frame, gdb_byte buf[sizeof(void*)]; struct z80_unwind_cache *info; struct gdbarch *gdbarch = get_frame_arch (this_frame); - int addr_len = gdbarch_tdep (gdbarch)->addr_length; + z80_gdbarch_tdep *tdep = (z80_gdbarch_tdep *) gdbarch_tdep (gdbarch); + int addr_len = tdep->addr_length; if (*this_prologue_cache) return (struct z80_unwind_cache *) *this_prologue_cache; @@ -692,7 +696,7 @@ z80_frame_prev_register (struct frame_info *this_frame, ULONGEST pc; gdb_byte buf[3]; struct gdbarch *gdbarch = get_frame_arch (this_frame); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + z80_gdbarch_tdep *tdep = (z80_gdbarch_tdep *) gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); read_memory (info->saved_regs[Z80_PC_REGNUM].addr (), @@ -745,11 +749,12 @@ z80_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) } else /* kind is non-RST address, use CALL instead, but it is dungerous */ { + z80_gdbarch_tdep *tdep = (z80_gdbarch_tdep *) gdbarch_tdep (gdbarch); gdb_byte *p = break_insn; *p++ = 0xcd; *p++ = (kind >> 0) & 0xff; *p++ = (kind >> 8) & 0xff; - if (gdbarch_tdep (gdbarch)->addr_length > 2) + if (tdep->addr_length > 2) *p++ = (kind >> 16) & 0xff; *size = p - break_insn; } @@ -1077,7 +1082,6 @@ static struct gdbarch * z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { struct gdbarch *gdbarch; - struct gdbarch_tdep *tdep; struct gdbarch_list *best_arch; tdesc_arch_data_up tdesc_data; unsigned long mach = info.bfd_arch_info->mach; @@ -1119,7 +1123,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } /* None found, create a new architecture from the information provided. */ - tdep = XCNEW (struct gdbarch_tdep); + z80_gdbarch_tdep *tdep = new z80_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); if (mach == bfd_mach_ez80_adl) -- cgit v1.1