mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-05 21:50:21 +08:00
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>
This commit is contained in:
@ -2671,7 +2671,6 @@ csky_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
|
||||
static struct gdbarch *
|
||||
csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
||||
{
|
||||
struct gdbarch *gdbarch;
|
||||
/* Analyze info.abfd. */
|
||||
unsigned int fpu_abi = 0;
|
||||
unsigned int vdsp_version = 0;
|
||||
@ -2761,8 +2760,10 @@ csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
||||
|
||||
/* None found, create a new architecture from the information
|
||||
provided. */
|
||||
csky_gdbarch_tdep *tdep = new csky_gdbarch_tdep;
|
||||
gdbarch = gdbarch_alloc (&info, tdep);
|
||||
gdbarch *gdbarch
|
||||
= gdbarch_alloc (&info, gdbarch_tdep_up (new csky_gdbarch_tdep));
|
||||
csky_gdbarch_tdep *tdep = gdbarch_tdep<csky_gdbarch_tdep> (gdbarch);
|
||||
|
||||
tdep->fpu_abi = fpu_abi;
|
||||
tdep->vdsp_version = vdsp_version;
|
||||
tdep->fpu_hardfp = fpu_hardfp;
|
||||
|
Reference in New Issue
Block a user