summaryrefslogtreecommitdiff
path: root/gdb/dwarf2/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2/expr.c')
-rw-r--r--gdb/dwarf2/expr.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 9986258333..3549745df0 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -34,30 +34,17 @@
#include "gdbarch.h"
#include "objfiles.h"
-/* Cookie for gdbarch data. */
-
-static struct gdbarch_data *dwarf_arch_cookie;
-
/* This holds gdbarch-specific types used by the DWARF expression
evaluator. See comments in execute_stack_op. */
struct dwarf_gdbarch_types
{
- struct type *dw_types[3];
+ struct type *dw_types[3] {};
};
-/* Allocate and fill in dwarf_gdbarch_types for an arch. */
-
-static void *
-dwarf_gdbarch_types_init (struct gdbarch *gdbarch)
-{
- struct dwarf_gdbarch_types *types
- = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf_gdbarch_types);
-
- /* The types themselves are lazily initialized. */
+/* Cookie for gdbarch data. */
- return types;
-}
+static const registry<gdbarch>::key<dwarf_gdbarch_types> dwarf_arch_cookie;
/* Ensure that a FRAME is defined, throw an exception otherwise. */
@@ -701,8 +688,9 @@ struct type *
dwarf_expr_context::address_type () const
{
gdbarch *arch = this->m_per_objfile->objfile->arch ();
- dwarf_gdbarch_types *types
- = (dwarf_gdbarch_types *) gdbarch_data (arch, dwarf_arch_cookie);
+ dwarf_gdbarch_types *types = dwarf_arch_cookie.get (arch);
+ if (types == nullptr)
+ types = dwarf_arch_cookie.emplace (arch);
int ndx;
if (this->m_addr_size == 2)
@@ -2398,11 +2386,3 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
this->m_recursion_depth--;
gdb_assert (this->m_recursion_depth >= 0);
}
-
-void _initialize_dwarf2expr ();
-void
-_initialize_dwarf2expr ()
-{
- dwarf_arch_cookie
- = gdbarch_data_register_post_init (dwarf_gdbarch_types_init);
-}