aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-06-01 15:31:15 -0600
committerTom Tromey <tom@tromey.com>2022-08-04 13:28:04 -0600
commitcb275538dbddfbb3c2c372a665ac48e6f617ea33 (patch)
tree7bc54ff4fc92c9b1cee74c2d7b9ae452b5ffec8b /gdb/solib.c
parent8b1540430107b0752485ab9e6a841dbbacd45681 (diff)
downloadgdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.zip
gdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.tar.gz
gdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.tar.bz2
Use registry in gdbarch
gdbarch implements its own registry-like approach. This patch changes it to instead use registry.h. It's a rather large patch but largely uninteresting -- it's mostly a straightforward conversion from the old approach to the new one. The main benefit of this change is that it introduces type safety to the gdbarch registry. It also removes a bunch of code. One possible drawback is that, previously, the gdbarch registry differentiated between pre- and post-initialization setup. This doesn't seem very important to me, though.
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index fc07f60..d889673 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -57,25 +57,14 @@
/* Architecture-specific operations. */
/* Per-architecture data key. */
-static struct gdbarch_data *solib_data;
-
-static void *
-solib_init (struct obstack *obstack)
-{
- struct target_so_ops **ops;
-
- ops = OBSTACK_ZALLOC (obstack, struct target_so_ops *);
- *ops = current_target_so_ops;
- return ops;
-}
+static const registry<gdbarch>::key<const struct target_so_ops,
+ gdb::noop_deleter<const struct target_so_ops>>
+ solib_data;
static const struct target_so_ops *
solib_ops (struct gdbarch *gdbarch)
{
- const struct target_so_ops **ops
- = (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data);
-
- return *ops;
+ return solib_data.get (gdbarch);
}
/* Set the solib operations for GDBARCH to NEW_OPS. */
@@ -83,10 +72,7 @@ solib_ops (struct gdbarch *gdbarch)
void
set_solib_ops (struct gdbarch *gdbarch, const struct target_so_ops *new_ops)
{
- const struct target_so_ops **ops
- = (const struct target_so_ops **) gdbarch_data (gdbarch, solib_data);
-
- *ops = new_ops;
+ solib_data.set (gdbarch, new_ops);
}
@@ -1786,8 +1772,6 @@ void _initialize_solib ();
void
_initialize_solib ()
{
- solib_data = gdbarch_data_register_pre_init (solib_init);
-
gdb::observers::free_objfile.attach (remove_user_added_objfile,
"solib");
gdb::observers::inferior_execd.attach ([] (inferior *inf)