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/nds32-tdep.c | |
parent | eae06bb301512a21277dd48a4bff025c4dceda9e (diff) | |
download | gdb-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.zip gdb-345bd07cce33565f1cd66acabdaf387ca3a7ccb3.tar.gz gdb-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/nds32-tdep.c')
-rw-r--r-- | gdb/nds32-tdep.c | 24 |
1 files changed, 12 insertions, 12 deletions
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; |