]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/arm-tdep.c
gdb: make gdbarch_alloc take ownership of the tdep
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 3 Oct 2022 15:15:14 +0000 (11:15 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Thu, 5 Jan 2023 19:38:51 +0000 (14:38 -0500)
commit2b16913cdca20ae1dafdbd816b025a6efdc6c06f
treee1b7e91c6e5f57f605ea37cf868f4987eedf078e
parentcabd67874a6ef7aaed41490d9eaddc4a4869a452
gdb: make gdbarch_alloc take ownership of the tdep

It's currently not clear how the ownership of gdbarch_tdep objects
works.  In fact, nothing ever takes ownership of it.  This is mostly
fine because we never free gdbarch objects, and thus we never free
gdbarch_tdep objects.  There is an exception to that however: when
initialization fails, we do free the gdbarch object that is not going to
be used, and we free the tdep too.  Currently, i386 and s390 do it.

To make things clearer, change gdbarch_alloc so that it takes ownership
of the tdep.  The tdep is thus automatically freed if the gdbarch is
freed.

Change all gdbarch initialization functions to pass a new gdbarch_tdep
object to gdbarch_alloc and then retrieve a non-owning reference from
the gdbarch object.

Before this patch, the xtensa architecture had a single global instance
of xtensa_gdbarch_tdep.  Since we need to pass a dynamically allocated
gdbarch_tdep_base instance to gdbarch_alloc, remove this global
instance, and dynamically allocate one as needed, like we do for all
other architectures.  Make the `rmap` array externally visible and
rename it to the less collision-prone `xtensa_rmap` name.

Change-Id: Id3d70493ef80ce4bdff701c57636f4c79ed8aea2
Approved-By: Andrew Burgess <aburgess@redhat.com>
46 files changed:
gdb/aarch64-tdep.c
gdb/alpha-tdep.c
gdb/arc-tdep.c
gdb/arch-utils.c
gdb/arm-tdep.c
gdb/avr-tdep.c
gdb/bfin-tdep.c
gdb/bpf-tdep.c
gdb/cris-tdep.c
gdb/csky-tdep.c
gdb/frv-tdep.c
gdb/ft32-tdep.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/hppa-tdep.c
gdb/i386-tdep.c
gdb/ia64-tdep.c
gdb/lm32-tdep.c
gdb/loongarch-tdep.c
gdb/m32c-tdep.c
gdb/m32r-tdep.c
gdb/m68hc11-tdep.c
gdb/m68k-tdep.c
gdb/mep-tdep.c
gdb/microblaze-tdep.c
gdb/mips-tdep.c
gdb/mn10300-tdep.c
gdb/moxie-tdep.c
gdb/msp430-tdep.c
gdb/nds32-tdep.c
gdb/nios2-tdep.c
gdb/or1k-tdep.c
gdb/riscv-tdep.c
gdb/rl78-tdep.c
gdb/rs6000-tdep.c
gdb/rx-tdep.c
gdb/s12z-tdep.c
gdb/s390-tdep.c
gdb/s390-tdep.h
gdb/sh-tdep.c
gdb/sparc-tdep.c
gdb/tic6x-tdep.c
gdb/v850-tdep.c
gdb/xtensa-config.c
gdb/xtensa-tdep.c
gdb/z80-tdep.c