aboutsummaryrefslogtreecommitdiff
path: root/gdb/netbsd-tdep.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/netbsd-tdep.c
parent8b1540430107b0752485ab9e6a841dbbacd45681 (diff)
downloadfsf-binutils-gdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.zip
fsf-binutils-gdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.tar.gz
fsf-binutils-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/netbsd-tdep.c')
-rw-r--r--gdb/netbsd-tdep.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c
index fbedb77..2e30aaf 100644
--- a/gdb/netbsd-tdep.c
+++ b/gdb/netbsd-tdep.c
@@ -373,24 +373,21 @@ nbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
return find_solib_trampoline_target (get_current_frame (), pc);
}
-static struct gdbarch_data *nbsd_gdbarch_data_handle;
-
struct nbsd_gdbarch_data
{
- struct type *siginfo_type;
+ struct type *siginfo_type = nullptr;
};
-static void *
-init_nbsd_gdbarch_data (struct gdbarch *gdbarch)
-{
- return GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nbsd_gdbarch_data);
-}
+static const registry<gdbarch>::key<nbsd_gdbarch_data>
+ nbsd_gdbarch_data_handle;
static struct nbsd_gdbarch_data *
get_nbsd_gdbarch_data (struct gdbarch *gdbarch)
{
- return ((struct nbsd_gdbarch_data *)
- gdbarch_data (gdbarch, nbsd_gdbarch_data_handle));
+ struct nbsd_gdbarch_data *result = nbsd_gdbarch_data_handle.get (gdbarch);
+ if (result == nullptr)
+ result = nbsd_gdbarch_data_handle.emplace (gdbarch);
+ return result;
}
/* Implement the "get_siginfo_type" gdbarch method. */
@@ -622,11 +619,3 @@ nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_xml_syscall_file_name (gdbarch, "syscalls/netbsd.xml");
set_gdbarch_get_syscall_number (gdbarch, nbsd_get_syscall_number);
}
-
-void _initialize_nbsd_tdep ();
-void
-_initialize_nbsd_tdep ()
-{
- nbsd_gdbarch_data_handle
- = gdbarch_data_register_post_init (init_nbsd_gdbarch_data);
-}