aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch/riscv.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/arch/riscv.c')
-rw-r--r--gdb/arch/riscv.c8
1 files changed, 5 insertions, 3 deletions
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);