aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/arch/aarch32.c12
-rw-r--r--gdb/arch/aarch64.c14
-rw-r--r--gdb/arch/amd64.c27
-rw-r--r--gdb/arch/arc.c25
-rw-r--r--gdb/arch/arc.h2
-rw-r--r--gdb/arch/arm.c16
-rw-r--r--gdb/arch/i386.c24
-rw-r--r--gdb/arch/riscv.h2
-rw-r--r--gdb/arch/tic6x.c14
-rw-r--r--gdbserver/ChangeLog5
-rw-r--r--gdbserver/linux-arc-low.cc6
12 files changed, 97 insertions, 69 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 75fdfeb..28fa696 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,24 @@
2020-10-09 Andrew Burgess <andrew.burgess@embecosm.com>
+ * arch/aarch32.c (aarch32_create_target_description): Release the
+ target_desc_up as late as possible.
+ * arch/aarch64.c (aarch64_create_target_description): Likewise.
+ * arch/amd64.c (amd64_create_target_description): Likewise.
+ * arch/arc.c (arc_create_target_description): Return a
+ target_desc_up, don't release it.
+ * arch/arc.h (arc_create_target_description): Update declaration.
+ (arc_lookup_target_description): Move target_desc_up into the
+ cache, and return a borrowed pointer.
+ * arch/arm.c (arm_create_target_description): Release the
+ target_desc_up as late as possible.
+ * arch/i386.c (i386_create_target_description): Likewise.
+ * arch/riscv.h (riscv_create_target_description): Update
+ declaration to match definition.
+ * arch/tic6x.c (tic6x_create_target_description): Release the
+ target_desc_up as late as possible.
+
+2020-10-09 Andrew Burgess <andrew.burgess@embecosm.com>
+
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
diff --git a/gdb/arch/aarch32.c b/gdb/arch/aarch32.c
index bf7a332..0a869ec 100644
--- a/gdb/arch/aarch32.c
+++ b/gdb/arch/aarch32.c
@@ -26,18 +26,18 @@
target_desc *
aarch32_create_target_description ()
{
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
- set_tdesc_architecture (tdesc, "arm");
+ set_tdesc_architecture (tdesc.get (), "arm");
#endif
long regnum = 0;
- regnum = create_feature_arm_arm_core (tdesc, regnum);
+ regnum = create_feature_arm_arm_core (tdesc.get (), regnum);
/* Create a vfpv3 feature, then a blank NEON feature. */
- regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
- tdesc_create_feature (tdesc, "org.gnu.gdb.arm.neon");
+ regnum = create_feature_arm_arm_vfpv3 (tdesc.get (), regnum);
+ tdesc_create_feature (tdesc.get (), "org.gnu.gdb.arm.neon");
- return tdesc;
+ return tdesc.release ();
}
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index c0af7b0..f89d5e0 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -29,23 +29,23 @@
target_desc *
aarch64_create_target_description (uint64_t vq, bool pauth_p)
{
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
- set_tdesc_architecture (tdesc, "aarch64");
+ set_tdesc_architecture (tdesc.get (), "aarch64");
#endif
long regnum = 0;
- regnum = create_feature_aarch64_core (tdesc, regnum);
+ regnum = create_feature_aarch64_core (tdesc.get (), regnum);
if (vq == 0)
- regnum = create_feature_aarch64_fpu (tdesc, regnum);
+ regnum = create_feature_aarch64_fpu (tdesc.get (), regnum);
else
- regnum = create_feature_aarch64_sve (tdesc, regnum, vq);
+ regnum = create_feature_aarch64_sve (tdesc.get (), regnum, vq);
if (pauth_p)
- regnum = create_feature_aarch64_pauth (tdesc, regnum);
+ regnum = create_feature_aarch64_pauth (tdesc.get (), regnum);
- return tdesc;
+ return tdesc.release ();
}
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index b11a4fd..60d997d 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -40,39 +40,40 @@ target_desc *
amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
bool segments)
{
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
- set_tdesc_architecture (tdesc, is_x32 ? "i386:x64-32" : "i386:x86-64");
+ set_tdesc_architecture (tdesc.get (),
+ is_x32 ? "i386:x64-32" : "i386:x86-64");
if (is_linux)
- set_tdesc_osabi (tdesc, "GNU/Linux");
+ set_tdesc_osabi (tdesc.get (), "GNU/Linux");
#endif
long regnum = 0;
if (is_x32)
- regnum = create_feature_i386_x32_core (tdesc, regnum);
+ regnum = create_feature_i386_x32_core (tdesc.get (), regnum);
else
- regnum = create_feature_i386_64bit_core (tdesc, regnum);
+ regnum = create_feature_i386_64bit_core (tdesc.get (), regnum);
- regnum = create_feature_i386_64bit_sse (tdesc, regnum);
+ regnum = create_feature_i386_64bit_sse (tdesc.get (), regnum);
if (is_linux)
- regnum = create_feature_i386_64bit_linux (tdesc, regnum);
+ regnum = create_feature_i386_64bit_linux (tdesc.get (), regnum);
if (segments)
- regnum = create_feature_i386_64bit_segments (tdesc, regnum);
+ regnum = create_feature_i386_64bit_segments (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_AVX)
- regnum = create_feature_i386_64bit_avx (tdesc, regnum);
+ regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
if ((xcr0 & X86_XSTATE_MPX) && !is_x32)
- regnum = create_feature_i386_64bit_mpx (tdesc, regnum);
+ regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_AVX512)
- regnum = create_feature_i386_64bit_avx512 (tdesc, regnum);
+ regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
if ((xcr0 & X86_XSTATE_PKRU) && !is_x32)
- regnum = create_feature_i386_64bit_pkeys (tdesc, regnum);
+ regnum = create_feature_i386_64bit_pkeys (tdesc.get (), regnum);
- return tdesc;
+ return tdesc.release ();
}
diff --git a/gdb/arch/arc.c b/gdb/arch/arc.c
index dff4575..abed8a6 100644
--- a/gdb/arch/arc.c
+++ b/gdb/arch/arc.c
@@ -34,11 +34,11 @@
#define STATIC_IN_GDB
#endif
-STATIC_IN_GDB target_desc *
+STATIC_IN_GDB target_desc_up
arc_create_target_description (const struct arc_arch_features &features)
{
/* Create a new target description. */
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
std::string arch_name;
@@ -57,7 +57,7 @@ arc_create_target_description (const struct arc_arch_features &features)
gdb_assert_not_reached (msg.c_str ());
}
- set_tdesc_architecture (tdesc, arch_name.c_str ());
+ set_tdesc_architecture (tdesc.get (), arch_name.c_str ());
#endif
long regnum = 0;
@@ -65,12 +65,12 @@ arc_create_target_description (const struct arc_arch_features &features)
switch (features.isa)
{
case ARC_ISA_ARCV1:
- regnum = create_feature_arc_v1_core (tdesc, regnum);
- regnum = create_feature_arc_v1_aux (tdesc, regnum);
+ regnum = create_feature_arc_v1_core (tdesc.get (), regnum);
+ regnum = create_feature_arc_v1_aux (tdesc.get (), regnum);
break;
case ARC_ISA_ARCV2:
- regnum = create_feature_arc_v2_core (tdesc, regnum);
- regnum = create_feature_arc_v2_aux (tdesc, regnum);
+ regnum = create_feature_arc_v2_core (tdesc.get (), regnum);
+ regnum = create_feature_arc_v2_aux (tdesc.get (), regnum);
break;
default:
std::string msg = string_printf
@@ -111,12 +111,15 @@ arc_lookup_target_description (const struct arc_arch_features &features)
if (it != arc_tdesc_cache.end ())
return it->second.get ();
- target_desc *tdesc = arc_create_target_description (features);
+ target_desc_up tdesc = arc_create_target_description (features);
- /* Add the newly created target description to the repertoire. */
- arc_tdesc_cache.emplace (features, 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 ();
+ arc_tdesc_cache.emplace (features, std::move (tdesc));
+ return ptr;
}
#endif /* !GDBSERVER */
diff --git a/gdb/arch/arc.h b/gdb/arch/arc.h
index 1625759..1e0e8cd 100644
--- a/gdb/arch/arc.h
+++ b/gdb/arch/arc.h
@@ -70,7 +70,7 @@ struct arc_arch_features
The only external client of this must be the gdbserver which manipulates
the returned data. */
-target_desc *arc_create_target_description
+target_desc_up arc_create_target_description
(const struct arc_arch_features &features);
#else
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index dc67e40..406a8e7 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -374,18 +374,18 @@ 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 ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
if (fp_type == ARM_FP_TYPE_IWMMXT)
- set_tdesc_architecture (tdesc, "iwmmxt");
+ set_tdesc_architecture (tdesc.get (), "iwmmxt");
else
- set_tdesc_architecture (tdesc, "arm");
+ set_tdesc_architecture (tdesc.get (), "arm");
#endif
long regnum = 0;
- regnum = create_feature_arm_arm_core (tdesc, regnum);
+ regnum = create_feature_arm_arm_core (tdesc.get (), regnum);
switch (fp_type)
{
@@ -393,22 +393,22 @@ arm_create_target_description (arm_fp_type fp_type)
break;
case ARM_FP_TYPE_VFPV2:
- regnum = create_feature_arm_arm_vfpv2 (tdesc, regnum);
+ regnum = create_feature_arm_arm_vfpv2 (tdesc.get (), regnum);
break;
case ARM_FP_TYPE_VFPV3:
- regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
+ regnum = create_feature_arm_arm_vfpv3 (tdesc.get (), regnum);
break;
case ARM_FP_TYPE_IWMMXT:
- regnum = create_feature_arm_xscale_iwmmxt (tdesc, regnum);
+ regnum = create_feature_arm_xscale_iwmmxt (tdesc.get (), regnum);
break;
default:
error (_("Invalid Arm FP type: %d"), fp_type);
}
- return tdesc;
+ return tdesc.release ();
}
/* See arch/arm.h. */
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 13201db..d823c1a 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -35,39 +35,39 @@
target_desc *
i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
{
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
#ifndef IN_PROCESS_AGENT
- set_tdesc_architecture (tdesc, "i386");
+ set_tdesc_architecture (tdesc.get (), "i386");
if (is_linux)
- set_tdesc_osabi (tdesc, "GNU/Linux");
+ set_tdesc_osabi (tdesc.get (), "GNU/Linux");
#endif
long regnum = 0;
if (xcr0 & X86_XSTATE_X87)
- regnum = create_feature_i386_32bit_core (tdesc, regnum);
+ regnum = create_feature_i386_32bit_core (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_SSE)
- regnum = create_feature_i386_32bit_sse (tdesc, regnum);
+ regnum = create_feature_i386_32bit_sse (tdesc.get (), regnum);
if (is_linux)
- regnum = create_feature_i386_32bit_linux (tdesc, regnum);
+ regnum = create_feature_i386_32bit_linux (tdesc.get (), regnum);
if (segments)
- regnum = create_feature_i386_32bit_segments (tdesc, regnum);
+ regnum = create_feature_i386_32bit_segments (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_AVX)
- regnum = create_feature_i386_32bit_avx (tdesc, regnum);
+ regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_MPX)
- regnum = create_feature_i386_32bit_mpx (tdesc, regnum);
+ regnum = create_feature_i386_32bit_mpx (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_AVX512)
- regnum = create_feature_i386_32bit_avx512 (tdesc, regnum);
+ regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
if (xcr0 & X86_XSTATE_PKRU)
- regnum = create_feature_i386_32bit_pkeys (tdesc, regnum);
+ regnum = create_feature_i386_32bit_pkeys (tdesc.get (), regnum);
- return tdesc;
+ return tdesc.release ();
}
diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index d40862c..26db0da 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -72,7 +72,7 @@ struct riscv_gdbarch_features
This is only used directly from the gdbserver where the created target
description is modified after it is return. */
-target_desc *riscv_create_target_description
+target_desc_up riscv_create_target_description
(const struct riscv_gdbarch_features features);
#else
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index dad4dd8..d52ec3a 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -28,20 +28,20 @@
target_desc *
tic6x_create_target_description (enum c6x_feature feature)
{
- target_desc *tdesc = allocate_target_description ().release ();
+ target_desc_up tdesc = allocate_target_description ();
- set_tdesc_architecture (tdesc, "tic6x");
- set_tdesc_osabi (tdesc, "GNU/Linux");
+ set_tdesc_architecture (tdesc.get (), "tic6x");
+ set_tdesc_osabi (tdesc.get (), "GNU/Linux");
long regnum = 0;
- regnum = create_feature_tic6x_core (tdesc, regnum);
+ regnum = create_feature_tic6x_core (tdesc.get (), regnum);
if (feature == C6X_GP || feature == C6X_C6XP)
- regnum = create_feature_tic6x_gp (tdesc, regnum);
+ regnum = create_feature_tic6x_gp (tdesc.get (), regnum);
if (feature == C6X_C6XP)
- regnum = create_feature_tic6x_c6xp (tdesc, regnum);
+ regnum = create_feature_tic6x_c6xp (tdesc.get (), regnum);
- return tdesc;
+ return tdesc.release ();
}
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 262ceff..79e6a37 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
2020-10-09 Andrew Burgess <andrew.burgess@embecosm.com>
+ * linux-arc-low.cc (arc_linux_read_description): Release the
+ unique_ptr returned from arc_create_target_description.
+
+2020-10-09 Andrew Burgess <andrew.burgess@embecosm.com>
+
* Makefile.in: Include Makefile.gnulib.inc. Don't define LIBGNU
or INCGNU. Make use of LIBGNU_EXTRA_LIBS when linking.
diff --git a/gdbserver/linux-arc-low.cc b/gdbserver/linux-arc-low.cc
index 1f370ef..d101bd2 100644
--- a/gdbserver/linux-arc-low.cc
+++ b/gdbserver/linux-arc-low.cc
@@ -112,12 +112,12 @@ arc_linux_read_description (void)
#else
arc_arch_features features (4, ARC_ISA_ARCV2);
#endif
- struct target_desc *tdesc = arc_create_target_description (features);
+ target_desc_up tdesc = arc_create_target_description (features);
static const char *expedite_regs[] = { "sp", "status32", nullptr };
- init_target_desc (tdesc, expedite_regs);
+ init_target_desc (tdesc.get (), expedite_regs);
- return tdesc;
+ return tdesc.release ();
}
void