aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/arch/riscv.c8
-rw-r--r--gdb/target-descriptions.c4
-rw-r--r--gdb/target-descriptions.h12
4 files changed, 21 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1b5bc8b..5a01458 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2020-07-17 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * arch/riscv.c (riscv_tdesc_cache): Change map type.
+ (riscv_lookup_target_description): Return pointer out of
+ unique_ptr.
+ * target-descriptions.c (allocate_target_description): Add
+ comment.
+ (target_desc_deleter::operator()): Likewise.
+ * target-descriptions.h (struct target_desc_deleter): Moved to
+ gdbsupport/tdesc.h.
+ (target_desc_up): Likewise.
+
2020-07-17 Tom Tromey <tromey@adacore.com>
* linux-nat.c (linux_nat_target::supports_non_stop)
diff --git a/gdb/arch/riscv.c b/gdb/arch/riscv.c
index a02c18b..e43aafc 100644
--- a/gdb/arch/riscv.c
+++ b/gdb/arch/riscv.c
@@ -91,7 +91,7 @@ struct riscv_gdbarch_features_hasher
/* Cache of previously seen target descriptions, indexed by the feature set
that created them. */
static std::unordered_map<riscv_gdbarch_features,
- const target_desc *,
+ const target_desc_up,
riscv_gdbarch_features_hasher> riscv_tdesc_cache;
/* See arch/riscv.h. */
@@ -99,10 +99,12 @@ static std::unordered_map<riscv_gdbarch_features,
const target_desc *
riscv_lookup_target_description (const struct riscv_gdbarch_features features)
{
- /* Lookup in the cache. */
+ /* Lookup in the cache. If we find it then return the pointer out of
+ the target_desc_up (which is a unique_ptr). This is safe as the
+ riscv_tdesc_cache will exist until GDB exits. */
const auto it = riscv_tdesc_cache.find (features);
if (it != riscv_tdesc_cache.end ())
- return it->second;
+ return it->second.get ();
target_desc *tdesc = riscv_create_target_description (features);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 2f4b177..20d624c 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1206,12 +1206,16 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name)
return new_feature;
}
+/* See gdbsupport/tdesc.h. */
+
struct target_desc *
allocate_target_description (void)
{
return new target_desc ();
}
+/* See gdbsupport/tdesc.h. */
+
void
target_desc_deleter::operator() (struct target_desc *target_desc) const
{
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index 6d842bf..66a2c21 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -225,18 +225,6 @@ struct type *tdesc_find_type (struct gdbarch *gdbarch, const char *id);
int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
struct reggroup *reggroup);
-
-/* A deleter adapter for a target desc. */
-
-struct target_desc_deleter
-{
- void operator() (struct target_desc *desc) const;
-};
-
-/* A unique pointer specialization that holds a target_desc. */
-
-typedef std::unique_ptr<target_desc, target_desc_deleter> target_desc_up;
-
/* Methods for constructing a target description. */
void set_tdesc_architecture (struct target_desc *,