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/gdbarch.h | |
parent | 8b1540430107b0752485ab9e6a841dbbacd45681 (diff) | |
download | fsf-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/gdbarch.h')
-rw-r--r-- | gdb/gdbarch.h | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 3249584..2c431a3 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -29,6 +29,7 @@ #include "osabi.h" #include "displaced-stepping.h" #include "gdbsupport/gdb-checked-static-cast.h" +#include "registry.h" struct floatformat; struct ui_file; @@ -351,32 +352,13 @@ extern struct gdbarch *gdbarch_find_by_info (struct gdbarch_info info); extern void set_target_gdbarch (struct gdbarch *gdbarch); -/* Register per-architecture data-pointer. - - Reserve space for a per-architecture data-pointer. An identifier - for the reserved data-pointer is returned. That identifer should - be saved in a local static variable. - - Memory for the per-architecture data shall be allocated using - gdbarch_obstack_zalloc. That memory will be deleted when the - corresponding architecture object is deleted. - - When a previously created architecture is re-selected, the - per-architecture data-pointer for that previous architecture is - restored. INIT() is not re-called. - - Multiple registrarants for any architecture are allowed (and - strongly encouraged). */ - -struct gdbarch_data; - -typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack); -extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init); -typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch); -extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init); - -extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *); - +/* A registry adaptor for gdbarch. This arranges to store the + registry in the gdbarch. */ +template<> +struct registry_accessor<gdbarch> +{ + static registry<gdbarch> *get (gdbarch *arch); +}; /* Set the dynamic target-system-dependent parameters (architecture, byte-order, ...) using information found in the BFD. */ |