+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)
/* 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. */
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);
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
{
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 *,
+2020-07-17 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * tdesc.cc (allocate_target_description): Add header comment.
+ (target_desc_deleter::operator()): New function.
+ * tdesc.h (struct target_desc): Declare as final.
+
2020-07-13 Simon Marchi <simon.marchi@polymtl.ca>
* server.cc (handle_query): Use std::vector of
#endif
}
+/* 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
+{
+ delete target_desc;
+}
+
#ifndef IN_PROCESS_AGENT
static const struct target_desc default_description {};
/* A target description. Inherit from tdesc_feature so that target_desc
can be used as tdesc_feature. */
-struct target_desc : tdesc_element
+struct target_desc final : tdesc_element
{
/* A vector of elements of register definitions that
describe the inferior's register set. */
+2020-07-17 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * tdesc.h (struct target_desc_deleter): Moved here
+ from gdb/target-descriptions.h, extend comment.
+ (target_desc_up): Likewise.
+
2020-06-30 Tom Tromey <tromey@adacore.com>
PR build/26183:
typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
+/* A deleter adapter for a target_desc. There are different
+ implementations of this deleter class in gdb and gdbserver because even
+ though the target_desc name is shared between the two projects, the
+ actual implementations of target_desc are completely different. */
+
+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;
+
/* Allocate a new target_desc. */
target_desc *allocate_target_description (void);