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/f-lang.c | |
parent | 8b1540430107b0752485ab9e6a841dbbacd45681 (diff) | |
download | gdb-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/f-lang.c')
-rw-r--r-- | gdb/f-lang.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 0f3de16..4b15950 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1720,11 +1720,10 @@ f_language::get_symbol_name_matcher_inner static f_language f_language_defn; -static void * +static struct builtin_f_type * build_fortran_types (struct gdbarch *gdbarch) { - struct builtin_f_type *builtin_f_type - = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_f_type); + struct builtin_f_type *builtin_f_type = new struct builtin_f_type; builtin_f_type->builtin_void = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); @@ -1794,12 +1793,19 @@ build_fortran_types (struct gdbarch *gdbarch) return builtin_f_type; } -static struct gdbarch_data *f_type_data; +static const registry<gdbarch>::key<struct builtin_f_type> f_type_data; const struct builtin_f_type * builtin_f_type (struct gdbarch *gdbarch) { - return (const struct builtin_f_type *) gdbarch_data (gdbarch, f_type_data); + struct builtin_f_type *result = f_type_data.get (gdbarch); + if (result == nullptr) + { + result = build_fortran_types (gdbarch); + f_type_data.set (gdbarch, result); + } + + return result; } /* Command-list for the "set/show fortran" prefix command. */ @@ -1810,8 +1816,6 @@ void _initialize_f_language (); void _initialize_f_language () { - f_type_data = gdbarch_data_register_post_init (build_fortran_types); - add_setshow_prefix_cmd ("fortran", no_class, _("Prefix command for changing Fortran-specific settings."), |