diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-15 11:29:39 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-11-15 11:29:39 -0500 |
commit | 345bd07cce33565f1cd66acabdaf387ca3a7ccb3 (patch) | |
tree | bfa86d2102817e06235193c865d2580e802d0a1a /gdb/sparc-tdep.h | |
parent | eae06bb301512a21277dd48a4bff025c4dceda9e (diff) | |
download | binutils-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.zip binutils-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.tar.gz binutils-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.tar.bz2 |
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 <arch>_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 <arch>_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
Diffstat (limited to 'gdb/sparc-tdep.h')
-rw-r--r-- | gdb/sparc-tdep.h | 43 |
1 files changed, 23 insertions, 20 deletions
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. */ |