gdb: fix gdbarch_tdep ODR violation
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 15 Nov 2021 16:29:39 +0000 (11:29 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 15 Nov 2021 16:29:39 +0000 (11:29 -0500)
commit345bd07cce33565f1cd66acabdaf387ca3a7ccb3
treebfa86d2102817e06235193c865d2580e802d0a1a
parenteae06bb301512a21277dd48a4bff025c4dceda9e
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
133 files changed:
gdb/aarch64-fbsd-tdep.c
gdb/aarch64-linux-tdep.c
gdb/aarch64-newlib-tdep.c
gdb/aarch64-tdep.c
gdb/aarch64-tdep.h
gdb/alpha-linux-tdep.c
gdb/alpha-netbsd-tdep.c
gdb/alpha-obsd-tdep.c
gdb/alpha-tdep.c
gdb/alpha-tdep.h
gdb/amd64-darwin-tdep.c
gdb/amd64-fbsd-tdep.c
gdb/amd64-linux-tdep.c
gdb/amd64-netbsd-tdep.c
gdb/amd64-obsd-tdep.c
gdb/amd64-sol2-tdep.c
gdb/amd64-tdep.c
gdb/amd64-windows-tdep.c
gdb/arc-linux-tdep.c
gdb/arc-tdep.c
gdb/arc-tdep.h
gdb/arm-fbsd-tdep.c
gdb/arm-linux-tdep.c
gdb/arm-netbsd-tdep.c
gdb/arm-none-tdep.c
gdb/arm-obsd-tdep.c
gdb/arm-tdep.c
gdb/arm-tdep.h
gdb/arm-wince-tdep.c
gdb/avr-tdep.c
gdb/bfin-tdep.c
gdb/bfin-tdep.h
gdb/bpf-tdep.c
gdb/cris-linux-tdep.c
gdb/cris-tdep.c
gdb/cris-tdep.h
gdb/csky-tdep.c
gdb/csky-tdep.h
gdb/frv-tdep.c
gdb/ft32-tdep.c
gdb/ft32-tdep.h
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/hppa-bsd-tdep.c
gdb/hppa-linux-tdep.c
gdb/hppa-tdep.c
gdb/hppa-tdep.h
gdb/i386-bsd-tdep.c
gdb/i386-darwin-tdep.c
gdb/i386-fbsd-tdep.c
gdb/i386-gnu-tdep.c
gdb/i386-go32-tdep.c
gdb/i386-linux-tdep.c
gdb/i386-netbsd-tdep.c
gdb/i386-nto-tdep.c
gdb/i386-obsd-tdep.c
gdb/i386-sol2-tdep.c
gdb/i386-tdep.c
gdb/i386-tdep.h
gdb/i386-windows-tdep.c
gdb/i387-tdep.c
gdb/ia64-linux-tdep.c
gdb/ia64-tdep.c
gdb/ia64-tdep.h
gdb/lm32-tdep.c
gdb/m32c-tdep.c
gdb/m32r-tdep.c
gdb/m32r-tdep.h
gdb/m68hc11-tdep.c
gdb/m68k-bsd-tdep.c
gdb/m68k-linux-tdep.c
gdb/m68k-tdep.c
gdb/m68k-tdep.h
gdb/mep-tdep.c
gdb/microblaze-tdep.c
gdb/microblaze-tdep.h
gdb/mips-linux-tdep.c
gdb/mips-tdep.c
gdb/mips-tdep.h
gdb/mn10300-tdep.c
gdb/mn10300-tdep.h
gdb/moxie-tdep.c
gdb/moxie-tdep.h
gdb/msp430-tdep.c
gdb/nds32-tdep.c
gdb/nds32-tdep.h
gdb/nios2-linux-tdep.c
gdb/nios2-tdep.c
gdb/nios2-tdep.h
gdb/or1k-tdep.c
gdb/ppc-fbsd-tdep.c
gdb/ppc-linux-tdep.c
gdb/ppc-netbsd-tdep.c
gdb/ppc-obsd-tdep.c
gdb/ppc-sysv-tdep.c
gdb/ppc-tdep.h
gdb/ppc64-tdep.c
gdb/riscv-linux-tdep.c
gdb/riscv-tdep.c
gdb/riscv-tdep.h
gdb/rl78-tdep.c
gdb/rs6000-aix-tdep.c
gdb/rs6000-lynx178-tdep.c
gdb/rs6000-tdep.c
gdb/rx-tdep.c
gdb/s12z-tdep.c
gdb/s390-linux-tdep.c
gdb/s390-tdep.c
gdb/s390-tdep.h
gdb/sh-linux-tdep.c
gdb/sh-netbsd-tdep.c
gdb/sh-tdep.c
gdb/sh-tdep.h
gdb/sparc-linux-tdep.c
gdb/sparc-netbsd-tdep.c
gdb/sparc-sol2-tdep.c
gdb/sparc-tdep.c
gdb/sparc-tdep.h
gdb/sparc64-fbsd-tdep.c
gdb/sparc64-linux-tdep.c
gdb/sparc64-netbsd-tdep.c
gdb/sparc64-obsd-tdep.c
gdb/sparc64-sol2-tdep.c
gdb/sparc64-tdep.c
gdb/tic6x-linux-tdep.c
gdb/tic6x-tdep.c
gdb/tic6x-tdep.h
gdb/v850-tdep.c
gdb/xtensa-config.c
gdb/xtensa-linux-tdep.c
gdb/xtensa-tdep.c
gdb/xtensa-tdep.h
gdb/z80-tdep.c