[v2,24/31] Convert mdebugread.c to type-safe registry API

Message ID 20190503231231.8954-25-tom@tromey.com
State New
Headers show
Series
  • Add a type-safe API to registries
Related show

Commit Message

Tom Tromey May 3, 2019, 11:12 p.m.
This changes mdebugread.c to use the type-safe registry API.

2019-05-01  Tom Tromey  <tom@tromey.com>

	* mdebugread.c (basic_type_data): Change type.
	(basic_type, _initialize_mdebugread): Update.
---
 gdb/ChangeLog    |  5 +++++
 gdb/mdebugread.c | 11 +++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 35e7890f357..2b54fef051a 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1358,14 +1358,15 @@  parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
 /* Basic types.  */
 
-static const struct objfile_data *basic_type_data;
+static const struct objfile_key<struct type *,
+				gdb::noop_deleter<struct type *>>
+  basic_type_data;
 
 static struct type *
 basic_type (int bt, struct objfile *objfile)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  struct type **map_bt
-    = (struct type **) objfile_data (objfile, basic_type_data);
+  struct type **map_bt = basic_type_data.get (objfile);
   struct type *tp;
 
   if (bt >= btMax)
@@ -1375,7 +1376,7 @@  basic_type (int bt, struct objfile *objfile)
     {
       map_bt = OBSTACK_CALLOC (&objfile->objfile_obstack,
 			       btMax, struct type *);
-      set_objfile_data (objfile, basic_type_data, map_bt);
+      basic_type_data.set (objfile, map_bt);
     }
 
   if (map_bt[bt])
@@ -4811,8 +4812,6 @@  elfmdebug_build_psymtabs (struct objfile *objfile,
 void
 _initialize_mdebugread (void)
 {
-  basic_type_data = register_objfile_data ();
-
   mdebug_register_index
     = register_symbol_register_impl (LOC_REGISTER, &mdebug_register_funcs);
   mdebug_regparm_index