diff options
author | Tom Tromey <tom@tromey.com> | 2022-06-01 15:31:15 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-08-04 13:28:04 -0600 |
commit | cb275538dbddfbb3c2c372a665ac48e6f617ea33 (patch) | |
tree | 7bc54ff4fc92c9b1cee74c2d7b9ae452b5ffec8b /gdb/ia64-libunwind-tdep.c | |
parent | 8b1540430107b0752485ab9e6a841dbbacd45681 (diff) | |
download | binutils-gdb-cb275538dbddfbb3c2c372a665ac48e6f617ea33.tar.gz |
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/ia64-libunwind-tdep.c')
-rw-r--r-- | gdb/ia64-libunwind-tdep.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c index a2a236a4667..4c788f20956 100644 --- a/gdb/ia64-libunwind-tdep.c +++ b/gdb/ia64-libunwind-tdep.c @@ -56,7 +56,7 @@ #endif static int libunwind_initialized; -static struct gdbarch_data *libunwind_descr_handle; +static const registry<gdbarch>::key<libunwind_descr> libunwind_descr_handle; /* Required function pointers from libunwind. */ typedef int (unw_get_reg_p_ftype) (unw_cursor_t *, unw_regnum_t, unw_word_t *); @@ -127,17 +127,10 @@ static const char *find_dyn_list_name = STRINGIFY(UNW_OBJ(find_dyn_list)); static struct libunwind_descr * libunwind_descr (struct gdbarch *gdbarch) { - return ((struct libunwind_descr *) - gdbarch_data (gdbarch, libunwind_descr_handle)); -} - -static void * -libunwind_descr_init (struct obstack *obstack) -{ - struct libunwind_descr *descr - = OBSTACK_ZALLOC (obstack, struct libunwind_descr); - - return descr; + struct libunwind_descr *result = libunwind_descr_handle.get (gdbarch); + if (result == nullptr) + result = libunwind_descr_handle.emplace (gdbarch); + return result; } void @@ -148,8 +141,7 @@ libunwind_frame_set_descr (struct gdbarch *gdbarch, gdb_assert (gdbarch != NULL); - arch_descr = ((struct libunwind_descr *) - gdbarch_data (gdbarch, libunwind_descr_handle)); + arch_descr = libunwind_descr (gdbarch); gdb_assert (arch_descr != NULL); /* Copy new descriptor info into arch descriptor. */ @@ -587,8 +579,5 @@ void _initialize_libunwind_frame (); void _initialize_libunwind_frame () { - libunwind_descr_handle - = gdbarch_data_register_pre_init (libunwind_descr_init); - libunwind_initialized = libunwind_load (); } |