aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-10-18 11:38:10 -0600
committerTom Tromey <tom@tromey.com>2022-07-28 14:16:50 -0600
commit08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63 (patch)
treee1050b58dcebee1150881f43f64c1c186955d240 /gdb/dwarf2/read.c
parent8f83e7b9262e08fa43ca6e645337511c68ddc52a (diff)
downloadgdb-08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63.zip
gdb-08b8a139c9e8adcb4ec12a8a17e5836b8b5acb63.tar.gz
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/dwarf2/read.c')
-rw-r--r--gdb/dwarf2/read.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index f7e55af..70419da 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -124,7 +124,8 @@ static bool check_physname = false;
static bool use_deprecated_index_sections = false;
/* This is used to store the data that is always per objfile. */
-static const objfile_key<dwarf2_per_objfile> dwarf2_objfile_data_key;
+static const registry<objfile>::key<dwarf2_per_objfile>
+ dwarf2_objfile_data_key;
/* These are used to store the dwarf2_per_bfd objects.
@@ -134,8 +135,9 @@ static const objfile_key<dwarf2_per_objfile> dwarf2_objfile_data_key;
Other objfiles are not going to share a dwarf2_per_bfd with any other
objfiles, so they'll have their own version kept in the _objfile_data_key
version. */
-static const struct bfd_key<dwarf2_per_bfd> dwarf2_per_bfd_bfd_data_key;
-static const struct objfile_key<dwarf2_per_bfd> dwarf2_per_bfd_objfile_data_key;
+static const registry<bfd>::key<dwarf2_per_bfd> dwarf2_per_bfd_bfd_data_key;
+static const registry<objfile>::key<dwarf2_per_bfd>
+ dwarf2_per_bfd_objfile_data_key;
/* The "aclass" indices for various kinds of computed DWARF symbols. */