[PATCH] gdb: Have allocate_target_description return a unique_ptr

Andrew Burgess
2020-10-05T19:47:44Z

Below is a rebased version of a patch I posted here:

https://sourceware.org/pipermail/gdb-patches/2020-July/170639.html

this recieved positive feedback at the time but was buried in some
other thread so may not have been widely seen. I thought it was
probably worth reposting this before merging just to see if anyone
else had any thoughts.

There's a lot of change here, but all of the *.c files that are marked
'Regenerate' in the ChangeLog follow much the same pattern, review one
of them and you've reviewed them all.

Thanks,
Andrew

---

Update allocate_target_description to return a target_desc_up, a
specialisation of unique_ptr.

This commit does not attempt to make use of the unique_ptr in the
best possible way, in almost all cases we immediately release the
pointer from within the unique_ptr and then continue as before.

There are a few places where it was easy to handle the unique_ptr, and
in these cases I've done that.

Everything under gdb/features/* is auto-regenerated.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* arch/aarch32.c (aarch32_create_target_description): Release
unique_ptr returned from allocate_target_description.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/amd64.c (amd64_create_target_description): Likewise.
* arch/arc.c (arc_create_target_description): Likewise.
* arch/arm.c (arm_create_target_description): Likewise.
* arch/i386.c (i386_create_target_description): Likewise.
* arch/riscv.c (riscv_create_target_description): Update return
type. Handle allocate_target_description returning a unique_ptr.
(riscv_lookup_target_description): Update to handle unique_ptr.
* arch/tic6x.c (tic6x_create_target_description): Release
unique_ptr returned from allocate_target_description.
* features/microblaze-with-stack-protect.c: Regenerate.
* features/microblaze.c: Regenerate.
* features/mips-dsp-linux.c: Regenerate.
* features/mips-linux.c: Regenerate.
* features/mips64-dsp-linux.c: Regenerate.
* features/mips64-linux.c: Regenerate.
* features/nds32.c: Regenerate.
* features/nios2.c: Regenerate.
* features/or1k.c: Regenerate.
* features/rs6000/powerpc-32.c: Regenerate.
* features/rs6000/powerpc-32l.c: Regenerate.
* features/rs6000/powerpc-403.c: Regenerate.
* features/rs6000/powerpc-403gc.c: Regenerate.
* features/rs6000/powerpc-405.c: Regenerate.
* features/rs6000/powerpc-505.c: Regenerate.
* features/rs6000/powerpc-601.c: Regenerate.
* features/rs6000/powerpc-602.c: Regenerate.
* features/rs6000/powerpc-603.c: Regenerate.
* features/rs6000/powerpc-604.c: Regenerate.
* features/rs6000/powerpc-64.c: Regenerate.
* features/rs6000/powerpc-64l.c: Regenerate.
* features/rs6000/powerpc-7400.c: Regenerate.
* features/rs6000/powerpc-750.c: Regenerate.
* features/rs6000/powerpc-860.c: Regenerate.
* features/rs6000/powerpc-altivec32.c: Regenerate.
* features/rs6000/powerpc-altivec32l.c: Regenerate.
* features/rs6000/powerpc-altivec64.c: Regenerate.
* features/rs6000/powerpc-altivec64l.c: Regenerate.
* features/rs6000/powerpc-e500.c: Regenerate.
* features/rs6000/powerpc-e500l.c: Regenerate.
* features/rs6000/powerpc-isa205-32l.c: Regenerate.
* features/rs6000/powerpc-isa205-64l.c: Regenerate.
* features/rs6000/powerpc-isa205-altivec32l.c: Regenerate.
* features/rs6000/powerpc-isa205-altivec64l.c: Regenerate.
* features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa205-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa205-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa207-htm-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa207-htm-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa207-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa207-vsx64l.c: Regenerate.
* features/rs6000/powerpc-vsx32.c: Regenerate.
* features/rs6000/powerpc-vsx32l.c: Regenerate.
* features/rs6000/powerpc-vsx64.c: Regenerate.
* features/rs6000/powerpc-vsx64l.c: Regenerate.
* features/rs6000/rs6000.c: Regenerate.
* features/rx.c: Regenerate.
* features/s390-gs-linux64.c: Regenerate.
* features/s390-linux32.c: Regenerate.
* features/s390-linux32v1.c: Regenerate.
* features/s390-linux32v2.c: Regenerate.
* features/s390-linux64.c: Regenerate.
* features/s390-linux64v1.c: Regenerate.
* features/s390-linux64v2.c: Regenerate.
* features/s390-te-linux64.c: Regenerate.
* features/s390-tevx-linux64.c: Regenerate.
* features/s390-vx-linux64.c: Regenerate.
* features/s390x-gs-linux64.c: Regenerate.
* features/s390x-linux64.c: Regenerate.
* features/s390x-linux64v1.c: Regenerate.
* features/s390x-linux64v2.c: Regenerate.
* features/s390x-te-linux64.c: Regenerate.
* features/s390x-tevx-linux64.c: Regenerate.
* features/s390x-vx-linux64.c: Regenerate.
* mips-tdep.c (_initialize_mips_tdep): Release unique_ptr returned
from allocate_target_description.
* target-descriptions.c (allocate_target_description): Update
return type.
(print_c_tdesc::visit_pre): Release unique_ptr returned from
allocate_target_description.

gdbserver/ChangeLog:

* linux-low.cc (linux_process_target::handle_extended_wait):
Release the unique_ptr returned from allocate_target_description.
* linux-riscv-low.cc (riscv_target::low_arch_setup): Likewise.
* linux-x86-low.cc (tdesc_amd64_linux_no_xml): Change type.
(tdesc_i386_linux_no_xml): Change type.
(x86_linux_read_description): Borrow pointer from unique_ptr
object.
(x86_target::get_ipa_tdesc_idx): Likewise.
(initialize_low_arch): Likewise.
* tdesc.cc (allocate_target_description): Update return type.

gdbsupport/ChangeLog:

* tdesc.h (allocate_target_description): Update return type.
---
gdb/ChangeLog | 86 +++++++++++++++++++
gdb/arch/aarch32.c | 2 +-
gdb/arch/aarch64.c | 2 +-
gdb/arch/amd64.c | 2 +-
gdb/arch/arc.c | 2 +-
gdb/arch/arm.c | 4 +-
gdb/arch/i386.c | 2 +-
gdb/arch/riscv.c | 27 +++---
gdb/arch/tic6x.c | 2 +-
gdb/features/microblaze-with-stack-protect.c | 2 +-
gdb/features/microblaze.c | 2 +-
gdb/features/mips-dsp-linux.c | 2 +-
gdb/features/mips-linux.c | 2 +-
gdb/features/mips64-dsp-linux.c | 2 +-
gdb/features/mips64-linux.c | 2 +-
gdb/features/nds32.c | 2 +-
gdb/features/nios2.c | 2 +-
gdb/features/or1k.c | 2 +-
gdb/features/rs6000/powerpc-32.c | 2 +-
gdb/features/rs6000/powerpc-32l.c | 2 +-
gdb/features/rs6000/powerpc-403.c | 2 +-
gdb/features/rs6000/powerpc-403gc.c | 2 +-
gdb/features/rs6000/powerpc-405.c | 2 +-
gdb/features/rs6000/powerpc-505.c | 2 +-
gdb/features/rs6000/powerpc-601.c | 2 +-
gdb/features/rs6000/powerpc-602.c | 2 +-
gdb/features/rs6000/powerpc-603.c | 2 +-
gdb/features/rs6000/powerpc-604.c | 2 +-
gdb/features/rs6000/powerpc-64.c | 2 +-
gdb/features/rs6000/powerpc-64l.c | 2 +-
gdb/features/rs6000/powerpc-7400.c | 2 +-
gdb/features/rs6000/powerpc-750.c | 2 +-
gdb/features/rs6000/powerpc-860.c | 2 +-
gdb/features/rs6000/powerpc-altivec32.c | 2 +-
gdb/features/rs6000/powerpc-altivec32l.c | 2 +-
gdb/features/rs6000/powerpc-altivec64.c | 2 +-
gdb/features/rs6000/powerpc-altivec64l.c | 2 +-
gdb/features/rs6000/powerpc-e500.c | 2 +-
gdb/features/rs6000/powerpc-e500l.c | 2 +-
gdb/features/rs6000/powerpc-isa205-32l.c | 2 +-
gdb/features/rs6000/powerpc-isa205-64l.c | 2 +-
.../rs6000/powerpc-isa205-altivec32l.c | 2 +-
.../rs6000/powerpc-isa205-altivec64l.c | 2 +-
.../rs6000/powerpc-isa205-ppr-dscr-vsx32l.c | 2 +-
.../rs6000/powerpc-isa205-ppr-dscr-vsx64l.c | 2 +-
gdb/features/rs6000/powerpc-isa205-vsx32l.c | 2 +-
gdb/features/rs6000/powerpc-isa205-vsx64l.c | 2 +-
.../rs6000/powerpc-isa207-htm-vsx32l.c | 2 +-
.../rs6000/powerpc-isa207-htm-vsx64l.c | 2 +-
gdb/features/rs6000/powerpc-isa207-vsx32l.c | 2 +-
gdb/features/rs6000/powerpc-isa207-vsx64l.c | 2 +-
gdb/features/rs6000/powerpc-vsx32.c | 2 +-
gdb/features/rs6000/powerpc-vsx32l.c | 2 +-
gdb/features/rs6000/powerpc-vsx64.c | 2 +-
gdb/features/rs6000/powerpc-vsx64l.c | 2 +-
gdb/features/rs6000/rs6000.c | 2 +-
gdb/features/rx.c | 2 +-
gdb/features/s390-gs-linux64.c | 2 +-
gdb/features/s390-linux32.c | 2 +-
gdb/features/s390-linux32v1.c | 2 +-
gdb/features/s390-linux32v2.c | 2 +-
gdb/features/s390-linux64.c | 2 +-
gdb/features/s390-linux64v1.c | 2 +-
gdb/features/s390-linux64v2.c | 2 +-
gdb/features/s390-te-linux64.c | 2 +-
gdb/features/s390-tevx-linux64.c | 2 +-
gdb/features/s390-vx-linux64.c | 2 +-
gdb/features/s390x-gs-linux64.c | 2 +-
gdb/features/s390x-linux64.c | 2 +-
gdb/features/s390x-linux64v1.c | 2 +-
gdb/features/s390x-linux64v2.c | 2 +-
gdb/features/s390x-te-linux64.c | 2 +-
gdb/features/s390x-tevx-linux64.c | 2 +-
gdb/features/s390x-vx-linux64.c | 2 +-
gdb/mips-tdep.c | 4 +-
gdb/target-descriptions.c | 6 +-
gdbserver/ChangeLog | 13 +++
gdbserver/linux-low.cc | 7 +-
gdbserver/linux-riscv-low.cc | 6 +-
gdbserver/linux-x86-low.cc | 14 +--
gdbserver/tdesc.cc | 4 +-
gdbsupport/ChangeLog | 4 +
gdbsupport/tdesc.h | 2 +-
83 files changed, 211 insertions(+), 108 deletions(-)

diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index 5bc24a30164..bf7a33230e0 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -26,7 +26,7 @@
target_desc *
aarch32_create_target_description ()
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc, "arm");
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index f6115434989..c0af7b0906f 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -29,7 +29,7 @@
target_desc *
aarch64_create_target_description (uint64_t vq, bool pauth_p)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc, "aarch64");
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index a388c7e49d1..b11a4fdc0fc 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -40,7 +40,7 @@ target_desc *
amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
bool segments)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc, is_x32 ? "i386:x64-32" : "i386:x86-64");
diff --git a/gdb/arch/arc.c b/gdb/arch/arc.c
index 8e126ca5a82..45aeb429f59 100644
--- a/gdb/arch/arc.c
+++ b/gdb/arch/arc.c
@@ -38,7 +38,7 @@ STATIC_IN_GDB target_desc *
arc_create_target_description (const struct arc_gdbarch_features &features)
{
/* Create a new target description. */
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
std::string arch_name;
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index faa2b4fbd4b..dc67e40f9cf 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -374,7 +374,7 @@ shifted_reg_val (struct regcache *regcache, unsigned long inst,
target_desc *
arm_create_target_description (arm_fp_type fp_type)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
if (fp_type == ARM_FP_TYPE_IWMMXT)
@@ -416,7 +416,7 @@ arm_create_target_description (arm_fp_type fp_type)
target_desc *
arm_create_mprofile_target_description (arm_m_profile_type m_type)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc, "arm");
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 099a20b98a2..13201db1d74 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -35,7 +35,7 @@
target_desc *
i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc, "i386");
diff --git a/gdb/arch/riscv.c b/gdb/arch/riscv.c
index 8f5709092e9..a6538dee541 100644
--- a/gdb/arch/riscv.c
+++ b/gdb/arch/riscv.c
@@ -33,11 +33,11 @@

/* See arch/riscv.h. */

-STATIC_IN_GDB target_desc *
+STATIC_IN_GDB target_desc_up
riscv_create_target_description (const struct riscv_gdbarch_features features)
{
/* Now we should create a new target description. */
- target_desc *tdesc = allocate_target_description ();
+ target_desc_up tdesc = allocate_target_description ();

#ifndef IN_PROCESS_AGENT
std::string arch_name = "riscv";
@@ -56,22 +56,22 @@ riscv_create_target_description (const struct riscv_gdbarch_features features)
else if (features.flen == 16)
arch_name.append ("q");

- set_tdesc_architecture (tdesc, arch_name.c_str ());
+ set_tdesc_architecture (tdesc.get (), arch_name.c_str ());
#endif

long regnum = 0;

/* For now we only support creating 32-bit or 64-bit x-registers. */
if (features.xlen == 4)
- regnum = create_feature_riscv_32bit_cpu (tdesc, regnum);
+ regnum = create_feature_riscv_32bit_cpu (tdesc.get (), regnum);
else if (features.xlen == 8)
- regnum = create_feature_riscv_64bit_cpu (tdesc, regnum);
+ regnum = create_feature_riscv_64bit_cpu (tdesc.get (), regnum);

/* For now we only support creating 32-bit or 64-bit f-registers. */
if (features.flen == 4)
- regnum = create_feature_riscv_32bit_fpu (tdesc, regnum);
+ regnum = create_feature_riscv_32bit_fpu (tdesc.get (), regnum);
else if (features.flen == 8)
- regnum = create_feature_riscv_64bit_fpu (tdesc, regnum);
+ regnum = create_feature_riscv_64bit_fpu (tdesc.get (), regnum);

return tdesc;
}
@@ -106,13 +106,14 @@ riscv_lookup_target_description (const struct riscv_gdbarch_features features)
if (it != riscv_tdesc_cache.end ())
return it->second.get ();

- target_desc *tdesc = riscv_create_target_description (features);
+ target_desc_up tdesc (riscv_create_target_description (features));

- /* Add to the cache. Work around a problem with g++ 4.8 (PR96537):
- Call the target_desc_up constructor explictly instead of implicitly. */
- riscv_tdesc_cache.emplace (features, target_desc_up (tdesc));
-
- return tdesc;
+ /* Add to the cache, and return a pointer borrowed from the
+ target_desc_up. This is safe as the cache (and the pointers
+ contained within it) are not deleted until GDB exits. */
+ target_desc *ptr = tdesc.get ();
+ riscv_tdesc_cache.emplace (features, std::move (tdesc));
+ return ptr;
}

#endif /* !GDBSERVER */
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index 5f14d34750b..dad4dd85a4d 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -28,7 +28,7 @@
target_desc *
tic6x_create_target_description (enum c6x_feature feature)
{
- target_desc *tdesc = allocate_target_description ();
+ target_desc *tdesc = allocate_target_description ().release ();

set_tdesc_architecture (tdesc, "tic6x");
set_tdesc_osabi (tdesc, "GNU/Linux");
diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
index b39aa198874..994750cd29c 100644
--- a/gdb/features/microblaze-with-stack-protect.c
+++ b/gdb/features/microblaze-with-stack-protect.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_microblaze_with_stack_protect;
static void
initialize_tdesc_microblaze_with_stack_protect (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
index 6c86fc07700..011e7e685f1 100644
--- a/gdb/features/microblaze.c
+++ b/gdb/features/microblaze.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_microblaze;
static void
initialize_tdesc_microblaze (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core");
diff --git a/gdb/features/mips-dsp-linux.c b/gdb/features/mips-dsp-linux.c
index 26e9c6b01de..4df8db526bc 100644
--- a/gdb/features/mips-dsp-linux.c
+++ b/gdb/features/mips-dsp-linux.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_mips_dsp_linux;
static void
initialize_tdesc_mips_dsp_linux (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("mips"));

set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
diff --git a/gdb/features/mips-linux.c b/gdb/features/mips-linux.c
index c9ad3ca7eba..8808ff25780 100644
--- a/gdb/features/mips-linux.c
+++ b/gdb/features/mips-linux.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_mips_linux;
static void
initialize_tdesc_mips_linux (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("mips"));

set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
diff --git a/gdb/features/mips64-dsp-linux.c b/gdb/features/mips64-dsp-linux.c
index 05317b70f4f..7a5fa080408 100644
--- a/gdb/features/mips64-dsp-linux.c
+++ b/gdb/features/mips64-dsp-linux.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_mips64_dsp_linux;
static void
initialize_tdesc_mips64_dsp_linux (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("mips"));

struct tdesc_feature *feature;
diff --git a/gdb/features/mips64-linux.c b/gdb/features/mips64-linux.c
index 4814152c430..c1fc8926ff1 100644
--- a/gdb/features/mips64-linux.c
+++ b/gdb/features/mips64-linux.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_mips64_linux;
static void
initialize_tdesc_mips64_linux (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("mips"));

struct tdesc_feature *feature;
diff --git a/gdb/features/nds32.c b/gdb/features/nds32.c
index 89b246b8ce0..e867949ca04 100644
--- a/gdb/features/nds32.c
+++ b/gdb/features/nds32.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_nds32;
static void
initialize_tdesc_nds32 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("n1h"));

struct tdesc_feature *feature;
diff --git a/gdb/features/nios2.c b/gdb/features/nios2.c
index 705f499e65b..fd26781faf4 100644
--- a/gdb/features/nios2.c
+++ b/gdb/features/nios2.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_nios2;
static void
initialize_tdesc_nios2 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("nios2"));

struct tdesc_feature *feature;
diff --git a/gdb/features/or1k.c b/gdb/features/or1k.c
index 9169cae940e..e85f32d0f93 100644
--- a/gdb/features/or1k.c
+++ b/gdb/features/or1k.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_or1k;
static void
initialize_tdesc_or1k (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("or1k"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-32.c b/gdb/features/rs6000/powerpc-32.c
index 39f5b14bb43..addda76ab8e 100644
--- a/gdb/features/rs6000/powerpc-32.c
+++ b/gdb/features/rs6000/powerpc-32.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_32;
static void
initialize_tdesc_powerpc_32 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-32l.c b/gdb/features/rs6000/powerpc-32l.c
index 8089c0434ee..22d9c990d8e 100644
--- a/gdb/features/rs6000/powerpc-32l.c
+++ b/gdb/features/rs6000/powerpc-32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_32l;
static void
initialize_tdesc_powerpc_32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-403.c b/gdb/features/rs6000/powerpc-403.c
index a9106f5c536..7c2dbc7c8b5 100644
--- a/gdb/features/rs6000/powerpc-403.c
+++ b/gdb/features/rs6000/powerpc-403.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_403;
static void
initialize_tdesc_powerpc_403 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-403gc.c b/gdb/features/rs6000/powerpc-403gc.c
index 402b747a48f..670f25ba3ec 100644
--- a/gdb/features/rs6000/powerpc-403gc.c
+++ b/gdb/features/rs6000/powerpc-403gc.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_403gc;
static void
initialize_tdesc_powerpc_403gc (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-405.c b/gdb/features/rs6000/powerpc-405.c
index bcfa1445d23..d0113311b9f 100644
--- a/gdb/features/rs6000/powerpc-405.c
+++ b/gdb/features/rs6000/powerpc-405.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_405;
static void
initialize_tdesc_powerpc_405 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-505.c b/gdb/features/rs6000/powerpc-505.c
index 09b0c7a3854..653d1322261 100644
--- a/gdb/features/rs6000/powerpc-505.c
+++ b/gdb/features/rs6000/powerpc-505.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_505;
static void
initialize_tdesc_powerpc_505 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-601.c b/gdb/features/rs6000/powerpc-601.c
index f30f5e66f82..bbf5d03ede0 100644
--- a/gdb/features/rs6000/powerpc-601.c
+++ b/gdb/features/rs6000/powerpc-601.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_601;
static void
initialize_tdesc_powerpc_601 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-602.c b/gdb/features/rs6000/powerpc-602.c
index 769671746ad..8d6b5b5c884 100644
--- a/gdb/features/rs6000/powerpc-602.c
+++ b/gdb/features/rs6000/powerpc-602.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_602;
static void
initialize_tdesc_powerpc_602 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-603.c b/gdb/features/rs6000/powerpc-603.c
index d5dae39b10d..ea74a74b738 100644
--- a/gdb/features/rs6000/powerpc-603.c
+++ b/gdb/features/rs6000/powerpc-603.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_603;
static void
initialize_tdesc_powerpc_603 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-604.c b/gdb/features/rs6000/powerpc-604.c
index 44dc8caf47e..6a4cea921fb 100644
--- a/gdb/features/rs6000/powerpc-604.c
+++ b/gdb/features/rs6000/powerpc-604.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_604;
static void
initialize_tdesc_powerpc_604 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-64.c b/gdb/features/rs6000/powerpc-64.c
index a9760a37d95..0e74d03011a 100644
--- a/gdb/features/rs6000/powerpc-64.c
+++ b/gdb/features/rs6000/powerpc-64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_64;
static void
initialize_tdesc_powerpc_64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-64l.c b/gdb/features/rs6000/powerpc-64l.c
index 408794e13a0..7eea0b10df2 100644
--- a/gdb/features/rs6000/powerpc-64l.c
+++ b/gdb/features/rs6000/powerpc-64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_64l;
static void
initialize_tdesc_powerpc_64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-7400.c b/gdb/features/rs6000/powerpc-7400.c
index 58f8a69a1e2..afa80c040a2 100644
--- a/gdb/features/rs6000/powerpc-7400.c
+++ b/gdb/features/rs6000/powerpc-7400.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_7400;
static void
initialize_tdesc_powerpc_7400 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-750.c b/gdb/features/rs6000/powerpc-750.c
index 099a478518f..91e7c97058e 100644
--- a/gdb/features/rs6000/powerpc-750.c
+++ b/gdb/features/rs6000/powerpc-750.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_750;
static void
initialize_tdesc_powerpc_750 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-860.c b/gdb/features/rs6000/powerpc-860.c
index 0692feb2a5e..3050a1ffbfd 100644
--- a/gdb/features/rs6000/powerpc-860.c
+++ b/gdb/features/rs6000/powerpc-860.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_860;
static void
initialize_tdesc_powerpc_860 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.power.core");
diff --git a/gdb/features/rs6000/powerpc-altivec32.c b/gdb/features/rs6000/powerpc-altivec32.c
index bbb36c8aa59..6928801830a 100644
--- a/gdb/features/rs6000/powerpc-altivec32.c
+++ b/gdb/features/rs6000/powerpc-altivec32.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_altivec32;
static void
initialize_tdesc_powerpc_altivec32 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-altivec32l.c b/gdb/features/rs6000/powerpc-altivec32l.c
index 81862cb9ef4..05cf5c39311 100644
--- a/gdb/features/rs6000/powerpc-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-altivec32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_altivec32l;
static void
initialize_tdesc_powerpc_altivec32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-altivec64.c b/gdb/features/rs6000/powerpc-altivec64.c
index f7a7c729637..fd5de0a4dac 100644
--- a/gdb/features/rs6000/powerpc-altivec64.c
+++ b/gdb/features/rs6000/powerpc-altivec64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_altivec64;
static void
initialize_tdesc_powerpc_altivec64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-altivec64l.c b/gdb/features/rs6000/powerpc-altivec64l.c
index ce0bc86137e..c8f427b8c93 100644
--- a/gdb/features/rs6000/powerpc-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-altivec64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_altivec64l;
static void
initialize_tdesc_powerpc_altivec64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-e500.c b/gdb/features/rs6000/powerpc-e500.c
index 4466bc79a9b..447eab49bd3 100644
--- a/gdb/features/rs6000/powerpc-e500.c
+++ b/gdb/features/rs6000/powerpc-e500.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_e500;
static void
initialize_tdesc_powerpc_e500 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:e500"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-e500l.c b/gdb/features/rs6000/powerpc-e500l.c
index 61acbf3dd31..1d0b798aee6 100644
--- a/gdb/features/rs6000/powerpc-e500l.c
+++ b/gdb/features/rs6000/powerpc-e500l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_e500l;
static void
initialize_tdesc_powerpc_e500l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:e500"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-32l.c b/gdb/features/rs6000/powerpc-isa205-32l.c
index de6548fdf7c..bab1945411a 100644
--- a/gdb/features/rs6000/powerpc-isa205-32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_32l;
static void
initialize_tdesc_powerpc_isa205_32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-64l.c b/gdb/features/rs6000/powerpc-isa205-64l.c
index cd3b2c10a6c..12e166aa9ac 100644
--- a/gdb/features/rs6000/powerpc-isa205-64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_64l;
static void
initialize_tdesc_powerpc_isa205_64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec32l.c b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
index 09f5c075c8a..fe9d1356c58 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_altivec32l;
static void
initialize_tdesc_powerpc_isa205_altivec32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-altivec64l.c b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
index 246fcef085c..e28b5a945a9 100644
--- a/gdb/features/rs6000/powerpc-isa205-altivec64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-altivec64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_altivec64l;
static void
initialize_tdesc_powerpc_isa205_altivec64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
index c8f56ea0294..8ec604b1a89 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx32l;
static void
initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
index 76e32f3b1b6..febb8542f10 100644
--- a/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_ppr_dscr_vsx64l;
static void
initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
index 2a6e232e994..6814536c4f2 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_vsx32l;
static void
initialize_tdesc_powerpc_isa205_vsx32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa205-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
index d0e32f29b1b..836f8e914bd 100644
--- a/gdb/features/rs6000/powerpc-isa205-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa205-vsx64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa205_vsx64l;
static void
initialize_tdesc_powerpc_isa205_vsx64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
index e1b933c8fb3..4edb5b37350 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa207_htm_vsx32l;
static void
initialize_tdesc_powerpc_isa207_htm_vsx32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
index 0d818d01593..decebc1a331 100644
--- a/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-htm-vsx64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa207_htm_vsx64l;
static void
initialize_tdesc_powerpc_isa207_htm_vsx64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx32l.c b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
index 8fe0f5e4384..9156b704789 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa207_vsx32l;
static void
initialize_tdesc_powerpc_isa207_vsx32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-isa207-vsx64l.c b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
index 0af1879e10a..0bfdaa39504 100644
--- a/gdb/features/rs6000/powerpc-isa207-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-isa207-vsx64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_isa207_vsx64l;
static void
initialize_tdesc_powerpc_isa207_vsx64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-vsx32.c b/gdb/features/rs6000/powerpc-vsx32.c
index 9eafb1c4823..11c2b05c5fd 100644
--- a/gdb/features/rs6000/powerpc-vsx32.c
+++ b/gdb/features/rs6000/powerpc-vsx32.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_vsx32;
static void
initialize_tdesc_powerpc_vsx32 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-vsx32l.c b/gdb/features/rs6000/powerpc-vsx32l.c
index f08df14f9e8..41411f3b969 100644
--- a/gdb/features/rs6000/powerpc-vsx32l.c
+++ b/gdb/features/rs6000/powerpc-vsx32l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_vsx32l;
static void
initialize_tdesc_powerpc_vsx32l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-vsx64.c b/gdb/features/rs6000/powerpc-vsx64.c
index 7991115cf6e..67ba593a969 100644
--- a/gdb/features/rs6000/powerpc-vsx64.c
+++ b/gdb/features/rs6000/powerpc-vsx64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_vsx64;
static void
initialize_tdesc_powerpc_vsx64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/powerpc-vsx64l.c b/gdb/features/rs6000/powerpc-vsx64l.c
index 1726e6754fd..6ead95b5cb6 100644
--- a/gdb/features/rs6000/powerpc-vsx64l.c
+++ b/gdb/features/rs6000/powerpc-vsx64l.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_powerpc_vsx64l;
static void
initialize_tdesc_powerpc_vsx64l (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("powerpc:common64"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rs6000/rs6000.c b/gdb/features/rs6000/rs6000.c
index 709b5da405d..39c2601c4e0 100644
--- a/gdb/features/rs6000/rs6000.c
+++ b/gdb/features/rs6000/rs6000.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_rs6000;
static void
initialize_tdesc_rs6000 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("rs6000:6000"));

struct tdesc_feature *feature;
diff --git a/gdb/features/rx.c b/gdb/features/rx.c
index d2c29c126f7..038b48b9db1 100644
--- a/gdb/features/rx.c
+++ b/gdb/features/rx.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_rx;
static void
initialize_tdesc_rx (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
struct tdesc_feature *feature;

feature = tdesc_create_feature (result, "org.gnu.gdb.rx.core");
diff --git a/gdb/features/s390-gs-linux64.c b/gdb/features/s390-gs-linux64.c
index 1416183d3db..2bd52258c51 100644
--- a/gdb/features/s390-gs-linux64.c
+++ b/gdb/features/s390-gs-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_gs_linux64;
static void
initialize_tdesc_s390_gs_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux32.c b/gdb/features/s390-linux32.c
index 01c136c933e..9336ee55d01 100644
--- a/gdb/features/s390-linux32.c
+++ b/gdb/features/s390-linux32.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux32;
static void
initialize_tdesc_s390_linux32 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux32v1.c b/gdb/features/s390-linux32v1.c
index 65a4a504d33..c9d9818e973 100644
--- a/gdb/features/s390-linux32v1.c
+++ b/gdb/features/s390-linux32v1.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux32v1;
static void
initialize_tdesc_s390_linux32v1 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux32v2.c b/gdb/features/s390-linux32v2.c
index b5d25ec75bf..bbf031fca85 100644
--- a/gdb/features/s390-linux32v2.c
+++ b/gdb/features/s390-linux32v2.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux32v2;
static void
initialize_tdesc_s390_linux32v2 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux64.c b/gdb/features/s390-linux64.c
index 531d3a1ca82..d3144b9e7bc 100644
--- a/gdb/features/s390-linux64.c
+++ b/gdb/features/s390-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux64;
static void
initialize_tdesc_s390_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux64v1.c b/gdb/features/s390-linux64v1.c
index d75deca23fa..fccee9d3629 100644
--- a/gdb/features/s390-linux64v1.c
+++ b/gdb/features/s390-linux64v1.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux64v1;
static void
initialize_tdesc_s390_linux64v1 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-linux64v2.c b/gdb/features/s390-linux64v2.c
index bd10ee8ffe3..5dd076b793c 100644
--- a/gdb/features/s390-linux64v2.c
+++ b/gdb/features/s390-linux64v2.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_linux64v2;
static void
initialize_tdesc_s390_linux64v2 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-te-linux64.c b/gdb/features/s390-te-linux64.c
index fe2020ac65a..260560e472f 100644
--- a/gdb/features/s390-te-linux64.c
+++ b/gdb/features/s390-te-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_te_linux64;
static void
initialize_tdesc_s390_te_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-tevx-linux64.c b/gdb/features/s390-tevx-linux64.c
index ae62e8de372..a03399e598e 100644
--- a/gdb/features/s390-tevx-linux64.c
+++ b/gdb/features/s390-tevx-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_tevx_linux64;
static void
initialize_tdesc_s390_tevx_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390-vx-linux64.c b/gdb/features/s390-vx-linux64.c
index d3ec0814608..cb632669d3e 100644
--- a/gdb/features/s390-vx-linux64.c
+++ b/gdb/features/s390-vx-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390_vx_linux64;
static void
initialize_tdesc_s390_vx_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:31-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-gs-linux64.c b/gdb/features/s390x-gs-linux64.c
index d253a09997a..3a822dd7646 100644
--- a/gdb/features/s390x-gs-linux64.c
+++ b/gdb/features/s390x-gs-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_gs_linux64;
static void
initialize_tdesc_s390x_gs_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-linux64.c b/gdb/features/s390x-linux64.c
index 9d48ea332bd..5b590cdea1a 100644
--- a/gdb/features/s390x-linux64.c
+++ b/gdb/features/s390x-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_linux64;
static void
initialize_tdesc_s390x_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-linux64v1.c b/gdb/features/s390x-linux64v1.c
index b95f1c4ccc2..4a36ecbe4ed 100644
--- a/gdb/features/s390x-linux64v1.c
+++ b/gdb/features/s390x-linux64v1.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_linux64v1;
static void
initialize_tdesc_s390x_linux64v1 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-linux64v2.c b/gdb/features/s390x-linux64v2.c
index 9aab89f458c..dc40e811d97 100644
--- a/gdb/features/s390x-linux64v2.c
+++ b/gdb/features/s390x-linux64v2.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_linux64v2;
static void
initialize_tdesc_s390x_linux64v2 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-te-linux64.c b/gdb/features/s390x-te-linux64.c
index babd3bdb03d..ce10bb6805e 100644
--- a/gdb/features/s390x-te-linux64.c
+++ b/gdb/features/s390x-te-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_te_linux64;
static void
initialize_tdesc_s390x_te_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-tevx-linux64.c b/gdb/features/s390x-tevx-linux64.c
index 1ac3249a054..7d6884b00e0 100644
--- a/gdb/features/s390x-tevx-linux64.c
+++ b/gdb/features/s390x-tevx-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_tevx_linux64;
static void
initialize_tdesc_s390x_tevx_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/features/s390x-vx-linux64.c b/gdb/features/s390x-vx-linux64.c
index 2e3d3824a26..c40c880646c 100644
--- a/gdb/features/s390x-vx-linux64.c
+++ b/gdb/features/s390x-vx-linux64.c
@@ -9,7 +9,7 @@ struct target_desc *tdesc_s390x_vx_linux64;
static void
initialize_tdesc_s390x_vx_linux64 (void)
{
- struct target_desc *result = allocate_target_description ();
+ struct target_desc *result = allocate_target_description ().release ();
set_tdesc_architecture (result, bfd_scan_arch ("s390:64-bit"));

struct tdesc_feature *feature;
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index b4ed734c5fb..317c7d092f1 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -8938,10 +8938,10 @@ _initialize_mips_tdep ()

/* Create feature sets with the appropriate properties. The values
are not important. */
- mips_tdesc_gp32 = allocate_target_description ();
+ mips_tdesc_gp32 = allocate_target_description ().release ();
set_tdesc_property (mips_tdesc_gp32, PROPERTY_GP32, "");

- mips_tdesc_gp64 = allocate_target_description ();
+ mips_tdesc_gp64 = allocate_target_description ().release ();
set_tdesc_property (mips_tdesc_gp64, PROPERTY_GP64, "");

/* Add root prefix command for all "set mips"/"show mips" commands. */
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 19dbcbeac39..33a8b28d193 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1207,10 +1207,10 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name)

/* See gdbsupport/tdesc.h. */

-struct target_desc *
+target_desc_up
allocate_target_description (void)
{
- return new target_desc ();
+ return target_desc_up (new target_desc ());
}

/* See gdbsupport/tdesc.h. */
@@ -1377,7 +1377,7 @@ class print_c_tdesc : public tdesc_element_visitor
printf_unfiltered ("initialize_tdesc_%s (void)\n", m_function);
printf_unfiltered ("{\n");
printf_unfiltered
- (" struct target_desc *result = allocate_target_description ();\n");
+ (" struct target_desc *result = allocate_target_description ().release ();\n");

if (tdesc_architecture (e) != NULL)
{
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1ae72a21d6c..06ce2f090ab 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -497,7 +497,6 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
struct process_info *child_proc;
struct lwp_info *child_lwp;
struct thread_info *child_thr;
- struct target_desc *tdesc;

ptid = ptid_t (new_pid, new_pid, 0);

@@ -553,9 +552,9 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,

clone_all_breakpoints (child_thr, event_thr);

- tdesc = allocate_target_description ();
- copy_target_description (tdesc, parent_proc->tdesc);
- child_proc->tdesc = tdesc;
+ target_desc_up tdesc = allocate_target_description ();
+ copy_target_description (tdesc.get (), parent_proc->tdesc);
+ child_proc->tdesc = tdesc.release ();

/* Clone arch-specific process data. */
low_new_fork (parent_proc, child_proc);
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 1c6e8c44dd9..32f191ea851 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -88,11 +88,11 @@ riscv_target::low_arch_setup ()

const riscv_gdbarch_features features
= riscv_linux_read_features (lwpid_of (current_thread));
- target_desc *tdesc = riscv_create_target_description (features);
+ target_desc_up tdesc = riscv_create_target_description (features);

if (!tdesc->expedite_regs)
- init_target_desc (tdesc, expedite_regs);
- current_process ()->tdesc = tdesc;
+ init_target_desc (tdesc.get (), expedite_regs);
+ current_process ()->tdesc = tdesc.release ();
}

/* Collect GPRs from REGCACHE into BUF. */
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index eeaced8c8d5..65a0c075705 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -48,9 +48,9 @@
#include "linux-x86-tdesc.h"

#ifdef __x86_64__
-static struct target_desc *tdesc_amd64_linux_no_xml;
+static target_desc_up tdesc_amd64_linux_no_xml;
#endif
-static struct target_desc *tdesc_i386_linux_no_xml;
+static target_desc_up tdesc_i386_linux_no_xml;

static unsigned char jump_insn[] = { 0xe9, 0, 0, 0, 0 };
@@ -899,10 +899,10 @@ x86_linux_read_description (void)
/* Don't use XML. */
#ifdef __x86_64__
if (machine == EM_X86_64)
- return tdesc_amd64_linux_no_xml;
+ return tdesc_amd64_linux_no_xml.get ();
else
#endif
- return tdesc_i386_linux_no_xml;
+ return tdesc_i386_linux_no_xml.get ();
}

if (have_ptrace_getregset == -1)
@@ -2955,7 +2955,7 @@ x86_target::get_ipa_tdesc_idx ()
return amd64_get_ipa_tdesc_idx (tdesc);
#endif

- if (tdesc == tdesc_i386_linux_no_xml)
+ if (tdesc == tdesc_i386_linux_no_xml.get ())
return X86_TDESC_SSE;

return i386_get_ipa_tdesc_idx (tdesc);
@@ -2971,14 +2971,14 @@ initialize_low_arch (void)
/* Initialize the Linux target descriptions. */
#ifdef __x86_64__
tdesc_amd64_linux_no_xml = allocate_target_description ();
- copy_target_description (tdesc_amd64_linux_no_xml,
+ copy_target_description (tdesc_amd64_linux_no_xml.get (),
amd64_linux_read_description (X86_XSTATE_SSE_MASK,
false));
tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
#endif

tdesc_i386_linux_no_xml = allocate_target_description ();
- copy_target_description (tdesc_i386_linux_no_xml,
+ copy_target_description (tdesc_i386_linux_no_xml.get (),
i386_linux_read_description (X86_XSTATE_SSE_MASK));
tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;

diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index e639017cc31..b7e6057ccbe 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -95,10 +95,10 @@ init_target_desc (struct target_desc *tdesc,

/* See gdbsupport/tdesc.h. */

-struct target_desc *
+target_desc_up
allocate_target_description (void)
{
- return new target_desc ();
+ return target_desc_up (new target_desc ());
}

/* See gdbsupport/tdesc.h. */
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index 14b5b5fc9b3..b70a56457da 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -328,7 +328,7 @@ struct target_desc_deleter
typedef std::unique_ptr<target_desc, target_desc_deleter> target_desc_up;

/* Allocate a new target_desc. */
-target_desc *allocate_target_description (void);
+target_desc_up allocate_target_description (void);

/* Set TARGET_DESC's architecture by NAME. */
void set_tdesc_architecture (target_desc *target_desc,
--
2.25.4