diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-18 11:38:10 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-07-28 14:16:50 -0600 |
commit | 08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63 (patch) | |
tree | e1050b58dcebee1150881f43f64c1c186955d240 /gdb/objfiles.c | |
parent | 8f83e7b9262e08fa43ca6e645337511c68ddc52a (diff) | |
download | fsf-binutils-gdb-08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63.zip fsf-binutils-gdb-08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63.tar.gz fsf-binutils-gdb-08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63.tar.bz2 |
Rewrite registry.h
This rewrites registry.h, removing all the macros and replacing it
with relatively ordinary template classes. The result is less code
than the previous setup. It replaces large macros with a relatively
straightforward C++ class, and now manages its own cleanup.
The existing type-safe "key" class is replaced with the equivalent
template class. This approach ended up requiring relatively few
changes to the users of the registry code in gdb -- code using the key
system just required a small change to the key's declaration.
All existing users of the old C-like API are now converted to use the
type-safe API. This mostly involved changing explicit deletion
functions to be an operator() in a deleter class.
The old "save/free" two-phase process is removed, and replaced with a
single "free" phase. No existing code used both phases.
The old "free" callbacks took a parameter for the enclosing container
object. However, this wasn't truly needed and is removed here as
well.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r-- | gdb/objfiles.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c index f462557..7759311 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -57,11 +57,6 @@ #include <algorithm> #include <vector> -/* Keep a registry of per-objfile data-pointers required by other GDB - modules. */ - -DEFINE_REGISTRY (objfile, REGISTRY_ACCESS_FIELD) - /* Externally visible variables that are owned by this module. See declarations in objfile.h for more info. */ @@ -85,7 +80,7 @@ struct objfile_pspace_info }; /* Per-program-space data key. */ -static const struct program_space_key<objfile_pspace_info> +static const registry<program_space>::key<objfile_pspace_info> objfiles_pspace_data; objfile_pspace_info::~objfile_pspace_info () @@ -112,7 +107,7 @@ get_objfile_pspace_data (struct program_space *pspace) /* Per-BFD data key. */ -static const struct bfd_key<objfile_per_bfd_storage> objfiles_bfd_data; +static const registry<bfd>::key<objfile_per_bfd_storage> objfiles_bfd_data; objfile_per_bfd_storage::~objfile_per_bfd_storage () { @@ -329,8 +324,6 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_) gdb_obstack.h specifies the alloc/dealloc functions. */ obstack_init (&objfile_obstack); - objfile_alloc_data (this); - std::string name_holder; if (name == NULL) { @@ -563,10 +556,6 @@ objfile::~objfile () if (sf != NULL) (*sf->sym_finish) (this); - /* Discard any data modules have associated with the objfile. The function - still may reference obfd. */ - objfile_free_data (this); - if (obfd) gdb_bfd_unref (obfd); else |