public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 21/31] Convert ada-lang.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (4 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 24/31] Convert mdebugread.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 13/31] Convert breakpoint.c " Tom Tromey
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes ada-lang.c to use the type-safe registry API.

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

	* ada-lang.c (struct ada_inferior_data): Add initializers.
	(ada_inferior_data): Change type.
	(ada_inferior_data_cleanup): Remove.
	(get_ada_inferior_data, ada_inferior_exit)
	(struct ada_pspace_data): Add initializers, destructor.
	(ada_pspace_data_handle): Change type.
	(get_ada_pspace_data): Update.
	(ada_pspace_data_cleanup): Remove.
---
 gdb/ChangeLog  | 11 +++++++++
 gdb/ada-lang.c | 63 +++++++++++++-------------------------------------
 2 files changed, 27 insertions(+), 47 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1a566635b2d..0efe7ddb065 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -378,27 +378,16 @@ struct ada_inferior_data
      tagged types.  With older versions of GNAT, this type was directly
      accessible through a component ("tsd") in the object tag.  But this
      is no longer the case, so we cache it for each inferior.  */
-  struct type *tsd_type;
+  struct type *tsd_type = nullptr;
 
   /* The exception_support_info data.  This data is used to determine
      how to implement support for Ada exception catchpoints in a given
      inferior.  */
-  const struct exception_support_info *exception_info;
+  const struct exception_support_info *exception_info = nullptr;
 };
 
 /* Our key to this module's inferior data.  */
-static const struct inferior_data *ada_inferior_data;
-
-/* A cleanup routine for our inferior data.  */
-static void
-ada_inferior_data_cleanup (struct inferior *inf, void *arg)
-{
-  struct ada_inferior_data *data;
-
-  data = (struct ada_inferior_data *) inferior_data (inf, ada_inferior_data);
-  if (data != NULL)
-    xfree (data);
-}
+static const struct inferior_key<ada_inferior_data> ada_inferior_data;
 
 /* Return our inferior data for the given inferior (INF).
 
@@ -413,12 +402,9 @@ get_ada_inferior_data (struct inferior *inf)
 {
   struct ada_inferior_data *data;
 
-  data = (struct ada_inferior_data *) inferior_data (inf, ada_inferior_data);
+  data = ada_inferior_data.get (inf);
   if (data == NULL)
-    {
-      data = XCNEW (struct ada_inferior_data);
-      set_inferior_data (inf, ada_inferior_data, data);
-    }
+    data = ada_inferior_data.emplace (inf);
 
   return data;
 }
@@ -429,8 +415,7 @@ get_ada_inferior_data (struct inferior *inf)
 static void
 ada_inferior_exit (struct inferior *inf)
 {
-  ada_inferior_data_cleanup (inf, NULL);
-  set_inferior_data (inf, ada_inferior_data, NULL);
+  ada_inferior_data.clear (inf);
 }
 
 
@@ -439,12 +424,18 @@ ada_inferior_exit (struct inferior *inf)
 /* This module's per-program-space data.  */
 struct ada_pspace_data
 {
+  ~ada_pspace_data ()
+  {
+    if (sym_cache != NULL)
+      ada_free_symbol_cache (sym_cache);
+  }
+
   /* The Ada symbol cache.  */
-  struct ada_symbol_cache *sym_cache;
+  struct ada_symbol_cache *sym_cache = nullptr;
 };
 
 /* Key to our per-program-space data.  */
-static const struct program_space_data *ada_pspace_data_handle;
+static const struct program_space_key<ada_pspace_data> ada_pspace_data_handle;
 
 /* Return this module's data for the given program space (PSPACE).
    If not is found, add a zero'ed one now.
@@ -456,29 +447,13 @@ get_ada_pspace_data (struct program_space *pspace)
 {
   struct ada_pspace_data *data;
 
-  data = ((struct ada_pspace_data *)
-	  program_space_data (pspace, ada_pspace_data_handle));
+  data = ada_pspace_data_handle.get (pspace);
   if (data == NULL)
-    {
-      data = XCNEW (struct ada_pspace_data);
-      set_program_space_data (pspace, ada_pspace_data_handle, data);
-    }
+    data = ada_pspace_data_handle.emplace (pspace);
 
   return data;
 }
 
-/* The cleanup callback for this module's per-program-space data.  */
-
-static void
-ada_pspace_data_cleanup (struct program_space *pspace, void *data)
-{
-  struct ada_pspace_data *pspace_data = (struct ada_pspace_data *) data;
-
-  if (pspace_data->sym_cache != NULL)
-    ada_free_symbol_cache (pspace_data->sym_cache);
-  xfree (pspace_data);
-}
-
                         /* Utilities */
 
 /* If TYPE is a TYPE_CODE_TYPEDEF type, return the target type after
@@ -14648,10 +14623,4 @@ DWARF attribute."),
   gdb::observers::new_objfile.attach (ada_new_objfile_observer);
   gdb::observers::free_objfile.attach (ada_free_objfile_observer);
   gdb::observers::inferior_exit.attach (ada_inferior_exit);
-
-  /* Setup various context-specific data.  */
-  ada_inferior_data
-    = register_inferior_data_with_cleanup (NULL, ada_inferior_data_cleanup);
-  ada_pspace_data_handle
-    = register_program_space_data_with_cleanup (NULL, ada_pspace_data_cleanup);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 25/31] Convert elfread.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (15 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 20/31] Convert coffread.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 18/31] Convert ada-tasks.c " Tom Tromey
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes elfread.c to use the type-safe registry API.  This also
fixes a potential memory leak, by changing the hash table so that it
is no longer allocated on an obstack.

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

	* elfread.c (elf_objfile_gnu_ifunc_cache_data): Change type.
	(elf_gnu_ifunc_record_cache): Update.  Don't allocate hash table
	on obstack.
	(elf_gnu_ifunc_resolve_by_cache, _initialize_elfread): Update.
---
 gdb/ChangeLog |  7 +++++++
 gdb/elfread.c | 18 ++++++++----------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index deee6f0baab..cb98b83f74b 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -639,7 +639,8 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
 
 /* The data pointer is htab_t for gnu_ifunc_record_cache_unchecked.  */
 
-static const struct objfile_data *elf_objfile_gnu_ifunc_cache_data;
+static const struct objfile_key<htab, htab_deleter>
+  elf_objfile_gnu_ifunc_cache_data;
 
 /* Map function names to CORE_ADDR in elf_objfile_gnu_ifunc_cache_data.  */
 
@@ -710,15 +711,13 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
   if (len > 4 && strcmp (target_name + len - 4, "@plt") == 0)
     return 0;
 
-  htab = (htab_t) objfile_data (objfile, elf_objfile_gnu_ifunc_cache_data);
+  htab = elf_objfile_gnu_ifunc_cache_data.get (objfile);
   if (htab == NULL)
     {
-      htab = htab_create_alloc_ex (1, elf_gnu_ifunc_cache_hash,
-				   elf_gnu_ifunc_cache_eq,
-				   NULL, &objfile->objfile_obstack,
-				   hashtab_obstack_allocate,
-				   dummy_obstack_deallocate);
-      set_objfile_data (objfile, elf_objfile_gnu_ifunc_cache_data, htab);
+      htab = htab_create_alloc (1, elf_gnu_ifunc_cache_hash,
+				elf_gnu_ifunc_cache_eq,
+				NULL, xcalloc, xfree);
+      elf_objfile_gnu_ifunc_cache_data.set (objfile, htab);
     }
 
   entry_local.addr = addr;
@@ -769,7 +768,7 @@ elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
       struct elf_gnu_ifunc_cache *entry_p;
       void **slot;
 
-      htab = (htab_t) objfile_data (objfile, elf_objfile_gnu_ifunc_cache_data);
+      htab = elf_objfile_gnu_ifunc_cache_data.get (objfile);
       if (htab == NULL)
 	continue;
 
@@ -1462,6 +1461,5 @@ _initialize_elfread (void)
 {
   add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
 
-  elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
   gnu_ifunc_fns_p = &elf_gnu_ifunc_fns;
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 18/31] Convert ada-tasks.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (16 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 25/31] Convert elfread.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 23/31] Add a noop deleter Tom Tromey
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes ada-tasks.c to use the type-safe registry API.

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

	* ada-tasks.c (ada_tasks_pspace_data_handle): Change type.
	(get_ada_tasks_pspace_data): Update.
	(ada_tasks_pspace_data_cleanup): Remove.
	(_initialize_tasks): Update.
	(ada_tasks_inferior_data_handle): Change type.
	(get_ada_tasks_inferior_data): Update.
	(ada_tasks_inferior_data_cleanup): Remove.
	(struct ada_tasks_pspace_data): Add initializers.
---
 gdb/ChangeLog   | 11 +++++++++
 gdb/ada-tasks.c | 59 ++++++++++++-------------------------------------
 2 files changed, 25 insertions(+), 45 deletions(-)

diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index ccabc631040..762fb868e75 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -142,35 +142,27 @@ struct ada_tasks_pspace_data
   /* Nonzero if the data has been initialized.  If set to zero,
      it means that the data has either not been initialized, or
      has potentially become stale.  */
-  int initialized_p;
+  int initialized_p = 0;
 
   /* The ATCB record type.  */
-  struct type *atcb_type;
+  struct type *atcb_type = nullptr;
 
   /* The ATCB "Common" component type.  */
-  struct type *atcb_common_type;
+  struct type *atcb_common_type = nullptr;
 
   /* The type of the "ll" field, from the atcb_common_type.  */
-  struct type *atcb_ll_type;
+  struct type *atcb_ll_type = nullptr;
 
   /* The type of the "call" field, from the atcb_common_type.  */
-  struct type *atcb_call_type;
+  struct type *atcb_call_type = nullptr;
 
   /* The index of various fields in the ATCB record and sub-records.  */
-  struct atcb_fieldnos atcb_fieldno;
+  struct atcb_fieldnos atcb_fieldno {};
 };
 
 /* Key to our per-program-space data.  */
-static const struct program_space_data *ada_tasks_pspace_data_handle;
-
-/* A cleanup routine for our per-program-space data.  */
-static void
-ada_tasks_pspace_data_cleanup (struct program_space *pspace, void *arg)
-{
-  struct ada_tasks_pspace_data *data
-    = (struct ada_tasks_pspace_data *) arg;
-  xfree (data);
-}
+static const struct program_space_key<ada_tasks_pspace_data>
+  ada_tasks_pspace_data_handle;
 
 /* The kind of data structure used by the runtime to store the list
    of Ada tasks.  */
@@ -245,7 +237,8 @@ struct ada_tasks_inferior_data
 };
 
 /* Key to our per-inferior data.  */
-static const struct inferior_data *ada_tasks_inferior_data_handle;
+static const struct inferior_key<ada_tasks_inferior_data>
+  ada_tasks_inferior_data_handle;
 
 /* Return the ada-tasks module's data for the given program space (PSPACE).
    If none is found, add a zero'ed one now.
@@ -257,13 +250,9 @@ get_ada_tasks_pspace_data (struct program_space *pspace)
 {
   struct ada_tasks_pspace_data *data;
 
-  data = ((struct ada_tasks_pspace_data *)
-	  program_space_data (pspace, ada_tasks_pspace_data_handle));
+  data = ada_tasks_pspace_data_handle.get (pspace);
   if (data == NULL)
-    {
-      data = XCNEW (struct ada_tasks_pspace_data);
-      set_program_space_data (pspace, ada_tasks_pspace_data_handle, data);
-    }
+    data = ada_tasks_pspace_data_handle.emplace (pspace);
 
   return data;
 }
@@ -285,26 +274,13 @@ get_ada_tasks_inferior_data (struct inferior *inf)
 {
   struct ada_tasks_inferior_data *data;
 
-  data = ((struct ada_tasks_inferior_data *)
-	  inferior_data (inf, ada_tasks_inferior_data_handle));
+  data = ada_tasks_inferior_data_handle.get (inf);
   if (data == NULL)
-    {
-      data = new ada_tasks_inferior_data;
-      set_inferior_data (inf, ada_tasks_inferior_data_handle, data);
-    }
+    data = ada_tasks_inferior_data_handle.emplace (inf);
 
   return data;
 }
 
-/* A cleanup routine for our per-inferior data.  */
-static void
-ada_tasks_inferior_data_cleanup (struct inferior *inf, void *arg)
-{
-  struct ada_tasks_inferior_data *data
-    = (struct ada_tasks_inferior_data *) arg;
-  delete data;
-}
-
 /* Return the task number of the task whose thread is THREAD, or zero
    if the task could not be found.  */
 
@@ -1431,13 +1407,6 @@ ada_tasks_new_objfile_observer (struct objfile *objfile)
 void
 _initialize_tasks (void)
 {
-  ada_tasks_pspace_data_handle
-    = register_program_space_data_with_cleanup (NULL,
-						ada_tasks_pspace_data_cleanup);
-  ada_tasks_inferior_data_handle
-    = register_inferior_data_with_cleanup (NULL,
-					   ada_tasks_inferior_data_cleanup);
-
   /* Attach various observers.  */
   gdb::observers::normal_stop.attach (ada_tasks_normal_stop_observer);
   gdb::observers::new_objfile.attach (ada_tasks_new_objfile_observer);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 15/31] Convert solib-svr4.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (6 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 13/31] Convert breakpoint.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 19/31] Convert fbsd-tdep.c " Tom Tromey
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes solib-svr4y.c to use the type-safe registry API.

2019-04-30  Tom Tromey  <tom@tromey.com>

	* solib-svr4.c (struct svr4_info): Add initializers and
	destructor.
	<probes_table>: Now an htab_up.
	(solib_svr4_pspace_data): Change type.
	(free_probes_table): Simplify.
	(~svr4_info): Rename from svr4_pspace_data_cleanup.
	(get_svr4_info, probes_table_htab_remove_objfile_probes)
	(probes_table_remove_objfile_probes, register_solib_event_probe)
	(solib_event_probe_at, svr4_update_solib_event_breakpoint)
	(_initialize_svr4_solib): Update.
---
 gdb/ChangeLog    | 13 +++++++++
 gdb/solib-svr4.c | 76 ++++++++++++++++++++----------------------------
 2 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 2aa7b95ce6c..2828c96c683 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -322,53 +322,53 @@ lm_addr_check (const struct so_list *so, bfd *abfd)
 
 struct svr4_info
 {
-  CORE_ADDR debug_base;	/* Base of dynamic linker structures.  */
+  svr4_info () = default;
+  ~svr4_info ();
+
+  /* Base of dynamic linker structures.  */
+  CORE_ADDR debug_base = 0;
 
   /* Validity flag for debug_loader_offset.  */
-  int debug_loader_offset_p;
+  int debug_loader_offset_p = 0;
 
   /* Load address for the dynamic linker, inferred.  */
-  CORE_ADDR debug_loader_offset;
+  CORE_ADDR debug_loader_offset = 0;
 
   /* Name of the dynamic linker, valid if debug_loader_offset_p.  */
-  char *debug_loader_name;
+  char *debug_loader_name = nullptr;
 
   /* Load map address for the main executable.  */
-  CORE_ADDR main_lm_addr;
+  CORE_ADDR main_lm_addr = 0;
 
-  CORE_ADDR interp_text_sect_low;
-  CORE_ADDR interp_text_sect_high;
-  CORE_ADDR interp_plt_sect_low;
-  CORE_ADDR interp_plt_sect_high;
+  CORE_ADDR interp_text_sect_low = 0;
+  CORE_ADDR interp_text_sect_high = 0;
+  CORE_ADDR interp_plt_sect_low = 0;
+  CORE_ADDR interp_plt_sect_high = 0;
 
   /* Nonzero if the list of objects was last obtained from the target
      via qXfer:libraries-svr4:read.  */
-  int using_xfer;
+  int using_xfer = 0;
 
   /* Table of struct probe_and_action instances, used by the
      probes-based interface to map breakpoint addresses to probes
      and their associated actions.  Lookup is performed using
      probe_and_action->prob->address.  */
-  htab_t probes_table;
+  htab_up probes_table;
 
   /* List of objects loaded into the inferior, used by the probes-
      based interface.  */
-  struct so_list *solib_list;
+  struct so_list *solib_list = nullptr;
 };
 
 /* Per-program-space data key.  */
-static const struct program_space_data *solib_svr4_pspace_data;
+static const struct program_space_key<svr4_info> solib_svr4_pspace_data;
 
 /* Free the probes table.  */
 
 static void
 free_probes_table (struct svr4_info *info)
 {
-  if (info->probes_table == NULL)
-    return;
-
-  htab_delete (info->probes_table);
-  info->probes_table = NULL;
+  info->probes_table.reset (nullptr);
 }
 
 /* Free the solib list.  */
@@ -380,15 +380,9 @@ free_solib_list (struct svr4_info *info)
   info->solib_list = NULL;
 }
 
-static void
-svr4_pspace_data_cleanup (struct program_space *pspace, void *arg)
+svr4_info::~svr4_info ()
 {
-  struct svr4_info *info = (struct svr4_info *) arg;
-
-  free_probes_table (info);
-  free_solib_list (info);
-
-  xfree (info);
+  free_solib_list (this);
 }
 
 /* Get the svr4 data for program space PSPACE.  If none is found yet, add it now.
@@ -397,15 +391,11 @@ svr4_pspace_data_cleanup (struct program_space *pspace, void *arg)
 static struct svr4_info *
 get_svr4_info (program_space *pspace)
 {
-  struct svr4_info *info;
+  struct svr4_info *info = solib_svr4_pspace_data.get (pspace);
 
-  info = (struct svr4_info *) program_space_data (pspace,
-						  solib_svr4_pspace_data);
-  if (info != NULL)
-    return info;
+  if (info == NULL)
+    info = solib_svr4_pspace_data.emplace (pspace);
 
-  info = XCNEW (struct svr4_info);
-  set_program_space_data (pspace, solib_svr4_pspace_data, info);
   return info;
 }
 
@@ -1677,7 +1667,8 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
   struct objfile *objfile = (struct objfile *) info;
 
   if (pa->objfile == objfile)
-    htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table, slot);
+    htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table.get (),
+		     slot);
 
   return 1;
 }
@@ -1689,7 +1680,7 @@ probes_table_remove_objfile_probes (struct objfile *objfile)
 {
   svr4_info *info = get_svr4_info (objfile->pspace);
   if (info->probes_table != nullptr)
-    htab_traverse_noresize (info->probes_table,
+    htab_traverse_noresize (info->probes_table.get (),
 			    probes_table_htab_remove_objfile_probes, objfile);
 }
 
@@ -1706,12 +1697,12 @@ register_solib_event_probe (svr4_info *info, struct objfile *objfile,
 
   /* Create the probes table, if necessary.  */
   if (info->probes_table == NULL)
-    info->probes_table = htab_create_alloc (1, hash_probe_and_action,
-					    equal_probe_and_action,
-					    xfree, xcalloc, xfree);
+    info->probes_table.reset (htab_create_alloc (1, hash_probe_and_action,
+						 equal_probe_and_action,
+						 xfree, xcalloc, xfree));
 
   lookup.address = address;
-  slot = htab_find_slot (info->probes_table, &lookup, INSERT);
+  slot = htab_find_slot (info->probes_table.get (), &lookup, INSERT);
   gdb_assert (*slot == HTAB_EMPTY_ENTRY);
 
   pa = XCNEW (struct probe_and_action);
@@ -1734,7 +1725,7 @@ solib_event_probe_at (struct svr4_info *info, CORE_ADDR address)
   void **slot;
 
   lookup.address = address;
-  slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT);
+  slot = htab_find_slot (info->probes_table.get (), &lookup, NO_INSERT);
 
   if (slot == NULL)
     return NULL;
@@ -2012,8 +2003,7 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
       struct svr4_info *info;
       struct probe_and_action *pa;
 
-      info = ((struct svr4_info *)
-	      program_space_data (loc->pspace, solib_svr4_pspace_data));
+      info = solib_svr4_pspace_data.get (loc->pspace);
       if (info == NULL || info->probes_table == NULL)
 	continue;
 
@@ -3243,8 +3233,6 @@ void
 _initialize_svr4_solib (void)
 {
   solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init);
-  solib_svr4_pspace_data
-    = register_program_space_data_with_cleanup (NULL, svr4_pspace_data_cleanup);
 
   svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
   svr4_so_ops.free_so = svr4_free_so;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 24/31] Convert mdebugread.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (3 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 07/31] Convert objfiles.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 21/31] Convert ada-lang.c " Tom Tromey
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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(-)

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
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 10/31] Convert symfile-debug.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (13 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 08/31] Convert auto-load.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 20/31] Convert coffread.c " Tom Tromey
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes symfile-debug.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* symfile-debug.c (struct debug_sym_fns_data): Add initializers.
	(symfile_debug_objfile_data_key): Change type.
	(symfile_debug_installed, debug_qf_has_symbols)
	(debug_qf_find_last_source_symtab)
	(debug_qf_forget_cached_source_info)
	(debug_qf_map_symtabs_matching_filename, debug_qf_lookup_symbol)
	(debug_qf_print_stats, debug_qf_dump)
	(debug_qf_expand_symtabs_for_function)
	(debug_qf_expand_all_symtabs)
	(debug_qf_expand_symtabs_with_fullname)
	(debug_qf_map_matching_symbols)
	(debug_qf_expand_symtabs_matching)
	(debug_qf_find_pc_sect_compunit_symtab)
	(debug_qf_map_symbol_filenames)
	(debug_qf_find_compunit_symtab_by_address, debug_sym_get_probes)
	(debug_sym_new_init, debug_sym_init, debug_sym_read)
	(debug_sym_read_psymbols, debug_sym_finish, debug_sym_offsets)
	(debug_sym_read_linetable, debug_sym_relocate): Update.
	(symfile_debug_free_objfile): Remove.
	(install_symfile_debug_logging, _initialize_symfile_debug):
	Update.
---
 gdb/ChangeLog       |  24 +++++++++++
 gdb/symfile-debug.c | 102 ++++++++++++++------------------------------
 2 files changed, 57 insertions(+), 69 deletions(-)

diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 5b3ae926504..8266ecbabf0 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -39,13 +39,14 @@
 
 struct debug_sym_fns_data
 {
-  const struct sym_fns *real_sf;
-  struct sym_fns debug_sf;
+  const struct sym_fns *real_sf = nullptr;
+  struct sym_fns debug_sf {};
 };
 
 /* We need to record a pointer to the real set of functions for each
    objfile.  */
-static const struct objfile_data *symfile_debug_objfile_data_key;
+static const struct objfile_key<debug_sym_fns_data>
+  symfile_debug_objfile_data_key;
 
 /* If non-zero all calls to the symfile functions are logged.  */
 static int debug_symfile = 0;
@@ -56,7 +57,7 @@ static int
 symfile_debug_installed (struct objfile *objfile)
 {
   return (objfile->sf != NULL
-	  && objfile_data (objfile, symfile_debug_objfile_data_key) != NULL);
+	  && symfile_debug_objfile_data_key.get (objfile) != NULL);
 }
 
 /* Utility return the name to print for SYMTAB.  */
@@ -73,8 +74,7 @@ static int
 debug_qf_has_symbols (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   int retval;
 
   retval = debug_data->real_sf->qf->has_symbols (objfile);
@@ -89,8 +89,7 @@ static struct symtab *
 debug_qf_find_last_source_symtab (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   struct symtab *retval;
 
   fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
@@ -108,8 +107,7 @@ static void
 debug_qf_forget_cached_source_info (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
 		    objfile_debug_name (objfile));
@@ -123,8 +121,7 @@ debug_qf_map_symtabs_matching_filename
    gdb::function_view<bool (symtab *)> callback)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s)\n",
@@ -147,8 +144,7 @@ debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
 			domain_enum domain)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   struct compunit_symtab *retval;
 
   fprintf_filtered (gdb_stdlog,
@@ -171,8 +167,7 @@ static void
 debug_qf_print_stats (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
 		    objfile_debug_name (objfile));
@@ -184,8 +179,7 @@ static void
 debug_qf_dump (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
 		    objfile_debug_name (objfile));
@@ -198,8 +192,7 @@ debug_qf_expand_symtabs_for_function (struct objfile *objfile,
 				      const char *func_name)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_for_function (%s, \"%s\")\n",
@@ -212,8 +205,7 @@ static void
 debug_qf_expand_all_symtabs (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
 		    objfile_debug_name (objfile));
@@ -226,8 +218,7 @@ debug_qf_expand_symtabs_with_fullname (struct objfile *objfile,
 				       const char *fullname)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
@@ -247,8 +238,7 @@ debug_qf_map_matching_symbols (struct objfile *objfile,
 			       symbol_compare_ftype *ordered_compare)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
@@ -276,8 +266,7 @@ debug_qf_expand_symtabs_matching
    enum search_domain kind)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog,
 		    "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
@@ -303,8 +292,7 @@ debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile,
 				       int warn_if_readin)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   struct compunit_symtab *retval;
 
   fprintf_filtered (gdb_stdlog,
@@ -335,8 +323,7 @@ debug_qf_map_symbol_filenames (struct objfile *objfile,
 			       int need_fullname)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   fprintf_filtered (gdb_stdlog,
 		    "qf->map_symbol_filenames (%s, %s, %s, %d)\n",
 		    objfile_debug_name (objfile),
@@ -353,8 +340,7 @@ debug_qf_find_compunit_symtab_by_address (struct objfile *objfile,
 					  CORE_ADDR address)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   fprintf_filtered (gdb_stdlog,
 		    "qf->find_compunit_symtab_by_address (%s, %s)\n",
 		    objfile_debug_name (objfile),
@@ -400,8 +386,7 @@ static const std::vector<probe *> &
 debug_sym_get_probes (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   const std::vector<probe *> &retval
     = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
@@ -425,8 +410,7 @@ static void
 debug_sym_new_init (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_new_init (%s)\n",
 		    objfile_debug_name (objfile));
@@ -438,8 +422,7 @@ static void
 debug_sym_init (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_init (%s)\n",
 		    objfile_debug_name (objfile));
@@ -451,8 +434,7 @@ static void
 debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
 		    objfile_debug_name (objfile), (unsigned) symfile_flags);
@@ -464,8 +446,7 @@ static void
 debug_sym_read_psymbols (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n",
 		    objfile_debug_name (objfile));
@@ -477,8 +458,7 @@ static void
 debug_sym_finish (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_finish (%s)\n",
 		    objfile_debug_name (objfile));
@@ -491,8 +471,7 @@ debug_sym_offsets (struct objfile *objfile,
 		   const section_addr_info &info)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_offsets (%s, %s)\n",
 		    objfile_debug_name (objfile),
@@ -514,8 +493,7 @@ static void
 debug_sym_read_linetable (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
 
   fprintf_filtered (gdb_stdlog, "sf->sym_read_linetable (%s)\n",
 		    objfile_debug_name (objfile));
@@ -527,8 +505,7 @@ static bfd_byte *
 debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf)
 {
   const struct debug_sym_fns_data *debug_data
-    = ((const struct debug_sym_fns_data *)
-       objfile_data (objfile, symfile_debug_objfile_data_key));
+    = symfile_debug_objfile_data_key.get (objfile);
   bfd_byte *retval;
 
   retval = debug_data->real_sf->sym_relocate (objfile, sectp, buf);
@@ -563,14 +540,6 @@ static const struct sym_fns debug_sym_fns =
   &debug_sym_quick_functions
 };
 \f
-/* Free the copy of sym_fns recorded in the registry.  */
-
-static void
-symfile_debug_free_objfile (struct objfile *objfile, void *datum)
-{
-  xfree (datum);
-}
-
 /* Install the debugging versions of the symfile functions for OBJFILE.
    Do not call this if the debug versions are already installed.  */
 
@@ -586,7 +555,7 @@ install_symfile_debug_logging (struct objfile *objfile)
   real_sf = objfile->sf;
 
   /* Alas we have to preserve NULL entries in REAL_SF.  */
-  debug_data = XCNEW (struct debug_sym_fns_data);
+  debug_data = new struct debug_sym_fns_data;
 
 #define COPY_SF_PTR(from, to, name, func)	\
   do {						\
@@ -612,7 +581,7 @@ install_symfile_debug_logging (struct objfile *objfile)
 #undef COPY_SF_PTR
 
   debug_data->real_sf = real_sf;
-  set_objfile_data (objfile, symfile_debug_objfile_data_key, debug_data);
+  symfile_debug_objfile_data_key.set (objfile, debug_data);
   objfile->sf = &debug_data->debug_sf;
 }
 
@@ -627,12 +596,10 @@ uninstall_symfile_debug_logging (struct objfile *objfile)
   /* The debug versions should be currently installed.  */
   gdb_assert (symfile_debug_installed (objfile));
 
-  debug_data = ((struct debug_sym_fns_data *)
-		objfile_data (objfile, symfile_debug_objfile_data_key));
+  debug_data = symfile_debug_objfile_data_key.get (objfile);
 
   objfile->sf = debug_data->real_sf;
-  xfree (debug_data);
-  set_objfile_data (objfile, symfile_debug_objfile_data_key, NULL);
+  symfile_debug_objfile_data_key.clear (objfile);
 }
 
 /* Call this function to set OBJFILE->SF.
@@ -687,9 +654,6 @@ show_debug_symfile (struct ui_file *file, int from_tty,
 void
 _initialize_symfile_debug (void)
 {
-  symfile_debug_objfile_data_key
-    = register_objfile_data_with_cleanup (NULL, symfile_debug_free_objfile);
-
   add_setshow_boolean_cmd ("symfile", no_class, &debug_symfile, _("\
 Set debugging of the symfile functions."), _("\
 Show debugging of the symfile functions."), _("\
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 16/31] Convert xcoffread.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 04/31] Convert target dcache " Tom Tromey
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes xcoffread.c to use the type-safe registry API.  It also
renames coff_symfile_info to xcoff_symfile_info, to avoid any possible
ODR violation.

2019-04-30  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (struct xcoff_symfile_info): Rename from
	coff_symfile_info.  Add initializers.
	(xcoff_objfile_data_key): Move lower.  Change type.
	(XCOFF_DATA): Rewrite.
	(xcoff_free_info): Remove.
	(xcoff_symfile_init, _initialize_xcoffread, read_xcoff_symtab)
	(read_symbol, read_symbol_lineno, find_linenos, init_stringtab)
	(xcoff_initial_scan): Update.
---
 gdb/ChangeLog   | 11 ++++++++++
 gdb/xcoffread.c | 57 ++++++++++++++++++-------------------------------
 2 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e93a34b411f..215645d6e11 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -53,10 +53,6 @@
 #include "aout/stab_gnu.h"
 
 \f
-/* Key for XCOFF-associated data.  */
-
-static const struct objfile_data *xcoff_objfile_data_key;
-
 /* We put a pointer to this structure in the read_symtab_private field
    of the psymtab.  */
 
@@ -125,32 +121,35 @@ static CORE_ADDR first_object_file_end;
 
 static unsigned local_symesz;
 
-struct coff_symfile_info
+struct xcoff_symfile_info
   {
-    file_ptr min_lineno_offset;	/* Where in file lowest line#s are.  */
-    file_ptr max_lineno_offset;	/* 1+last byte of line#s in file.  */
+    file_ptr min_lineno_offset {};	/* Where in file lowest line#s are.  */
+    file_ptr max_lineno_offset {};	/* 1+last byte of line#s in file.  */
 
     /* Pointer to the string table.  */
-    char *strtbl;
+    char *strtbl = nullptr;
 
     /* Pointer to debug section.  */
-    char *debugsec;
+    char *debugsec = nullptr;
 
     /* Pointer to the a.out symbol table.  */
-    char *symtbl;
+    char *symtbl = nullptr;
 
     /* Number of symbols in symtbl.  */
-    int symtbl_num_syms;
+    int symtbl_num_syms = 0;
 
     /* Offset in data section to TOC anchor.  */
-    CORE_ADDR toc_offset;
+    CORE_ADDR toc_offset = 0;
   };
 
+/* Key for XCOFF-associated data.  */
+
+static const struct objfile_key<xcoff_symfile_info> xcoff_objfile_data_key;
+
 /* Convenience macro to access the per-objfile XCOFF data.  */
 
 #define XCOFF_DATA(objfile)						\
-  ((struct coff_symfile_info *) objfile_data ((objfile),		\
-					      xcoff_objfile_data_key))
+  xcoff_objfile_data_key.get (objfile)
 
 /* XCOFF names for dwarf sections.  There is no compressed sections.  */
 
@@ -1006,7 +1005,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
 {
   bfd *abfd = objfile->obfd;
   char *raw_auxptr;		/* Pointer to first raw aux entry for sym.  */
-  struct coff_symfile_info *xcoff = XCOFF_DATA (objfile);
+  struct xcoff_symfile_info *xcoff = XCOFF_DATA (objfile);
   char *strtbl = xcoff->strtbl;
   char *debugsec = xcoff->debugsec;
   const char *debugfmt = bfd_xcoff_is_xcoff64 (abfd) ? "XCOFF64" : "XCOFF";
@@ -1710,7 +1709,7 @@ coff_getfilename (union internal_auxent *aux_entry, struct objfile *objfile)
 static void
 read_symbol (struct internal_syment *symbol, int symno)
 {
-  struct coff_symfile_info *xcoff = XCOFF_DATA (this_symtab_objfile);
+  struct xcoff_symfile_info *xcoff = XCOFF_DATA (this_symtab_objfile);
   int nsyms = xcoff->symtbl_num_syms;
   char *stbl = xcoff->symtbl;
 
@@ -1747,7 +1746,7 @@ read_symbol_lineno (int symno)
   struct objfile *objfile = this_symtab_objfile;
   int xcoff64 = bfd_xcoff_is_xcoff64 (objfile->obfd);
 
-  struct coff_symfile_info *info = XCOFF_DATA (objfile);
+  struct xcoff_symfile_info *info = XCOFF_DATA (objfile);
   int nsyms = info->symtbl_num_syms;
   char *stbl = info->symtbl;
   char *strtbl = info->strtbl;
@@ -1813,7 +1812,7 @@ gotit:
 static void
 find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
 {
-  struct coff_symfile_info *info;
+  struct xcoff_symfile_info *info;
   int size, count;
   file_ptr offset, maxoff;
 
@@ -1823,7 +1822,7 @@ find_linenos (struct bfd *abfd, struct bfd_section *asect, void *vpinfo)
     return;
 
   size = count * coff_data (abfd)->local_linesz;
-  info = (struct coff_symfile_info *) vpinfo;
+  info = (struct xcoff_symfile_info *) vpinfo;
   offset = asect->line_filepos;
   maxoff = offset + size;
 
@@ -1934,11 +1933,8 @@ xcoff_new_init (struct objfile *objfile)
 static void
 xcoff_symfile_init (struct objfile *objfile)
 {
-  struct coff_symfile_info *xcoff;
-
   /* Allocate struct to keep track of the symfile.  */
-  xcoff = XNEW (struct coff_symfile_info);
-  set_objfile_data (objfile, xcoff_objfile_data_key, xcoff);
+  xcoff_objfile_data_key.emplace (objfile);
 
   /* XCOFF objects may be reordered, so set OBJF_REORDERED.  If we
      find this causes a significant slowdown in gdb then we could
@@ -1971,7 +1967,7 @@ init_stringtab (bfd *abfd, file_ptr offset, struct objfile *objfile)
   int val;
   unsigned char lengthbuf[4];
   char *strtbl;
-  struct coff_symfile_info *xcoff = XCOFF_DATA (objfile);
+  struct xcoff_symfile_info *xcoff = XCOFF_DATA (objfile);
 
   xcoff->strtbl = NULL;
 
@@ -2925,7 +2921,7 @@ xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
   int num_symbols;		/* # of symbols */
   file_ptr symtab_offset;	/* symbol table and */
   file_ptr stringtab_offset;	/* string table file offsets */
-  struct coff_symfile_info *info;
+  struct xcoff_symfile_info *info;
   const char *name;
   unsigned int size;
 
@@ -3143,19 +3139,8 @@ xcoff_get_n_import_files (bfd *abfd)
   return l_nimpid - 1;
 }
 
-/* Free the per-objfile xcoff data.  */
-
-static void
-xcoff_free_info (struct objfile *objfile, void *arg)
-{
-  xfree (arg);
-}
-
 void
 _initialize_xcoffread (void)
 {
   add_symtab_fns (bfd_target_xcoff_flavour, &xcoff_sym_fns);
-
-  xcoff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
-							       xcoff_free_info);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 20/31] Convert coffread.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (14 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 10/31] Convert symfile-debug.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 25/31] Convert elfread.c " Tom Tromey
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes coffread.c to use the type-safe registry API.

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

	* coffread.c (struct coff_symfile_info): Add initializers.
	(coff_objfile_data_key): Move lower.  Change type.
	(coff_symfile_init, coff_symfile_read, _initialize_coffread):
	Update.
	(coff_free_info): Remove.
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/coffread.c | 38 ++++++++++++--------------------------
 2 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/gdb/coffread.c b/gdb/coffread.c
index 4354741ab64..0956f3897b4 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -43,26 +43,26 @@
 #include "psymtab.h"
 #include "build-id.h"
 
-/* Key for COFF-associated data.  */
-
-static const struct objfile_data *coff_objfile_data_key;
-
 /* The objfile we are currently reading.  */
 
 static struct objfile *coffread_objfile;
 
 struct coff_symfile_info
   {
-    file_ptr min_lineno_offset;	/* Where in file lowest line#s are.  */
-    file_ptr max_lineno_offset;	/* 1+last byte of line#s in file.  */
+    file_ptr min_lineno_offset = 0;	/* Where in file lowest line#s are.  */
+    file_ptr max_lineno_offset = 0;	/* 1+last byte of line#s in file.  */
 
-    CORE_ADDR textaddr;		/* Addr of .text section.  */
-    unsigned int textsize;	/* Size of .text section.  */
+    CORE_ADDR textaddr = 0;		/* Addr of .text section.  */
+    unsigned int textsize = 0;	/* Size of .text section.  */
     std::vector<asection *> *stabsects;	/* .stab sections.  */
-    asection *stabstrsect;	/* Section pointer for .stab section.  */
-    char *stabstrdata;
+    asection *stabstrsect = nullptr;	/* Section pointer for .stab section.  */
+    char *stabstrdata = nullptr;
   };
 
+/* Key for COFF-associated data.  */
+
+static const struct objfile_key<coff_symfile_info> coff_objfile_data_key;
+
 /* Translate an external name string into a user-visible name.  */
 #define	EXTERNAL_NAME(string, abfd) \
 	(string[0] == bfd_get_symbol_leading_char (abfd) \
@@ -485,15 +485,13 @@ static void
 coff_symfile_init (struct objfile *objfile)
 {
   struct dbx_symfile_info *dbx;
-  struct coff_symfile_info *coff;
 
   /* Allocate struct to keep track of stab reading.  */
   dbx = XCNEW (struct dbx_symfile_info);
   set_objfile_data (objfile, dbx_objfile_data_key, dbx);
 
   /* Allocate struct to keep track of the symfile.  */
-  coff = XCNEW (struct coff_symfile_info);
-  set_objfile_data (objfile, coff_objfile_data_key, coff);
+  coff_objfile_data_key.emplace (objfile);
 
   /* COFF objects may be reordered, so set OBJF_REORDERED.  If we
      find this causes a significant slowdown in gdb then we could
@@ -554,8 +552,7 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
   int stringtab_offset;
   int stabstrsize;
   
-  info = (struct coff_symfile_info *) objfile_data (objfile,
-						    coff_objfile_data_key);
+  info = coff_objfile_data_key.get (objfile);
   symfile_bfd = abfd;		/* Kludge for swap routines.  */
 
   std::vector<asection *> stabsects;
@@ -2211,22 +2208,11 @@ static const struct sym_fns coff_sym_fns =
   &psym_functions
 };
 
-/* Free the per-objfile COFF data.  */
-
-static void
-coff_free_info (struct objfile *objfile, void *arg)
-{
-  xfree (arg);
-}
-
 void
 _initialize_coffread (void)
 {
   add_symtab_fns (bfd_target_coff_flavour, &coff_sym_fns);
 
-  coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
-							      coff_free_info);
-
   coff_register_index
     = register_symbol_register_impl (LOC_REGISTER, &coff_register_funcs);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 07/31] Convert objfiles.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (2 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 05/31] Convert inflow " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 24/31] Convert mdebugread.c " Tom Tromey
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes objfiles.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* objfiles.c (objfile_pspace_info): Add destructor and
	initializers.
	(objfiles_pspace_data): Change type.
	(~objfile_pspace_info): Rename from objfiles_pspace_data_cleanup.
	(get_objfile_pspace_data): Update.
	(objfiles_bfd_data): Change type.
	(get_objfile_bfd_data): Update.
	(objfile_bfd_data_free, _initialize_objfiles): Remove.
---
 gdb/ChangeLog  | 11 ++++++++++
 gdb/objfiles.c | 59 +++++++++++++++-----------------------------------
 2 files changed, 28 insertions(+), 42 deletions(-)

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 1b0ea29980d..0f5c7381aa6 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -66,30 +66,30 @@ DEFINE_REGISTRY (objfile, REGISTRY_ACCESS_FIELD)
 
 struct objfile_pspace_info
 {
-  struct obj_section **sections;
-  int num_sections;
+  objfile_pspace_info () = default;
+  ~objfile_pspace_info ();
+
+  struct obj_section **sections = nullptr;
+  int num_sections = 0;
 
   /* Nonzero if object files have been added since the section map
      was last updated.  */
-  int new_objfiles_available;
+  int new_objfiles_available = 0;
 
   /* Nonzero if the section map MUST be updated before use.  */
-  int section_map_dirty;
+  int section_map_dirty = 0;
 
   /* Nonzero if section map updates should be inhibited if possible.  */
-  int inhibit_updates;
+  int inhibit_updates = 0;
 };
 
 /* Per-program-space data key.  */
-static const struct program_space_data *objfiles_pspace_data;
+static const struct program_space_key<objfile_pspace_info>
+  objfiles_pspace_data;
 
-static void
-objfiles_pspace_data_cleanup (struct program_space *pspace, void *arg)
+objfile_pspace_info::~objfile_pspace_info ()
 {
-  struct objfile_pspace_info *info = (struct objfile_pspace_info *) arg;
-
-  xfree (info->sections);
-  xfree (info);
+  xfree (sections);
 }
 
 /* Get the current svr4 data.  If none is found yet, add it now.  This
@@ -100,13 +100,9 @@ get_objfile_pspace_data (struct program_space *pspace)
 {
   struct objfile_pspace_info *info;
 
-  info = ((struct objfile_pspace_info *)
-	  program_space_data (pspace, objfiles_pspace_data));
+  info = objfiles_pspace_data.get (pspace);
   if (info == NULL)
-    {
-      info = XCNEW (struct objfile_pspace_info);
-      set_program_space_data (pspace, objfiles_pspace_data, info);
-    }
+    info = objfiles_pspace_data.emplace (pspace);
 
   return info;
 }
@@ -115,7 +111,7 @@ get_objfile_pspace_data (struct program_space *pspace)
 
 /* Per-BFD data key.  */
 
-static const struct bfd_data *objfiles_bfd_data;
+static const struct bfd_key<objfile_per_bfd_storage> objfiles_bfd_data;
 
 objfile_per_bfd_storage::~objfile_per_bfd_storage ()
 {
@@ -133,8 +129,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
   struct objfile_per_bfd_storage *storage = NULL;
 
   if (abfd != NULL)
-    storage = ((struct objfile_per_bfd_storage *)
-	       bfd_data (abfd, objfiles_bfd_data));
+    storage = objfiles_bfd_data.get (abfd);
 
   if (storage == NULL)
     {
@@ -143,7 +138,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
 	 back to not sharing data across users.  These cases are rare
 	 enough that this seems reasonable.  */
       if (abfd != NULL && !gdb_bfd_requires_relocations (abfd))
-	set_bfd_data (abfd, objfiles_bfd_data, storage);
+	objfiles_bfd_data.set (abfd, storage);
 
       /* Look up the gdbarch associated with the BFD.  */
       if (abfd != NULL)
@@ -153,15 +148,6 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
   return storage;
 }
 
-/* A deleter for objfile_per_bfd_storage that can be passed as a
-   cleanup function to the BFD registry.  */
-
-static void
-objfile_bfd_data_free (struct bfd *unused, void *d)
-{
-  delete (struct objfile_per_bfd_storage *) d;
-}
-
 /* See objfiles.h.  */
 
 void
@@ -1511,14 +1497,3 @@ objfile_flavour_name (struct objfile *objfile)
     return bfd_flavour_name (bfd_get_flavour (objfile->obfd));
   return NULL;
 }
-
-void
-_initialize_objfiles (void)
-{
-  objfiles_pspace_data
-    = register_program_space_data_with_cleanup (NULL,
-						objfiles_pspace_data_cleanup);
-
-  objfiles_bfd_data = register_bfd_data_with_cleanup (NULL,
-						      objfile_bfd_data_free);
-}
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 01/31] Add a type-safe C++ interface to a registry
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (18 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 23/31] Add a noop deleter Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 28/31] Convert stabsread.c to type-safe registry API Tom Tromey
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes DECLARE_REGISTRY to add a type-safe interface.  This
interface is a C++ class that handles the details of registering a
key, and provides various useful methods, including policy-based
cleanup.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* registry.h (DECLARE_REGISTRY): Define the _key class.
---
 gdb/ChangeLog  |  4 +++
 gdb/registry.h | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/gdb/registry.h b/gdb/registry.h
index 3881e29b54f..683d905f763 100644
--- a/gdb/registry.h
+++ b/gdb/registry.h
@@ -20,6 +20,8 @@
 #ifndef REGISTRY_H
 #define REGISTRY_H
 
+#include <type_traits>
+
 /* The macros here implement a template type and functions for
    associating some user data with a container object.
 
@@ -243,11 +245,65 @@ typedef void (*registry_ ## TAG ## _callback) (struct TAG *, void *);	\
 extern const struct TAG ## _data *register_ ## TAG ## _data (void);	\
 extern const struct TAG ## _data *register_ ## TAG ## _data_with_cleanup \
  (registry_ ## TAG ## _callback save, registry_ ## TAG ## _callback free); \
-extern void clear_ ## TAG ## _data (struct TAG *);		\
-extern void set_ ## TAG ## _data (struct TAG *,			\
-				  const struct TAG ## _data *data, \
-				  void *value);			\
-extern void *TAG ## _data (struct TAG *,			\
-			   const struct TAG ## _data *data);
+extern void clear_ ## TAG ## _data (struct TAG *);			\
+extern void set_ ## TAG ## _data (struct TAG *,				\
+				  const struct TAG ## _data *data,	\
+				  void *value);				\
+extern void *TAG ## _data (struct TAG *,				\
+			   const struct TAG ## _data *data);		\
+									\
+template<typename DATA, typename Deleter = std::default_delete<DATA>>	\
+class TAG ## _key							\
+{									\
+public:									\
+									\
+  TAG ## _key ()							\
+    : m_key (register_ ## TAG ## _data_with_cleanup (nullptr,		\
+						     cleanup))		\
+  {									\
+  }									\
+									\
+  DATA *get (struct TAG *obj) const					\
+  {									\
+    return (DATA *) TAG ## _data (obj, m_key);				\
+  }									\
+									\
+  void set (struct TAG *obj, DATA *data) const				\
+  {									\
+    set_ ## TAG ## _data (obj, m_key, data);				\
+  }									\
+									\
+  template<typename Dummy = DATA *, typename... Args>			\
+  typename std::enable_if<std::is_same<Deleter,				\
+				       std::default_delete<DATA>>::value, \
+			  Dummy>::type					\
+  emplace (struct TAG *obj, Args &&...args) const			\
+  {									\
+    DATA *result = new DATA (std::forward<Args> (args)...);		\
+    set (obj, result);							\
+    return result;							\
+  }									\
+									\
+  void clear (struct TAG *obj) const					\
+  {									\
+    DATA *datum = get (obj);						\
+    if (datum != nullptr)						\
+      {									\
+	cleanup (obj, datum);						\
+	set (obj, nullptr);						\
+      }									\
+  }									\
+									\
+private:								\
+									\
+  static void cleanup (struct TAG *obj, void *arg)			\
+  {									\
+    DATA *datum = (DATA *) arg;						\
+    Deleter d;								\
+    d (datum);								\
+  }									\
+									\
+  const struct TAG ## _data *m_key;					\
+};
 
 #endif /* REGISTRY_H */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 17/31] Convert probes to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (10 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 03/31] Convert symbol_cache " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 12/31] Convert linux-tdep.c " Tom Tromey
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the probes code in elfread.c to use the type-safe
registry API.  While doing this, I saw that the caller of get_probes
owns the probes, so I went through the code and changed the vectors to
store unique_ptrs, making the ownership relationship more clear.

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

	* symfile.h (struct sym_probe_fns) <sym_get_probes>: Change type.
	* symfile-debug.c (debug_sym_get_probes): Change type.
	* stap-probe.c (handle_stap_probe):
	(stap_static_probe_ops::get_probes): Change type.
	* probe.h (class static_probe_ops) <get_probes>: Change type.
	* probe.c (class any_static_probe_ops) <get_probes>: Change type.
	(parse_probes_in_pspace): Update.
	(find_probes_in_objfile, find_probe_by_pc, collect_probes):
	Update.
	(any_static_probe_ops::get_probes): Change type.
	* elfread.c (elfread_data): New typedef.
	(probe_key): Change type.
	(elf_get_probes): Likewise.  Update.
	(probe_key_free): Remove.
	(_initialize_elfread): Update.
	* dtrace-probe.c (class dtrace_static_probe_ops) <get_probes>:
	Change type.
	(dtrace_process_dof_probe, dtrace_process_dof)
	(dtrace_static_probe_ops::get_probe): Change type.
---
 gdb/ChangeLog       | 22 ++++++++++++++++++++++
 gdb/dtrace-probe.c  | 14 ++++++++------
 gdb/elfread.c       | 32 ++++++++------------------------
 gdb/probe.c         | 28 ++++++++++++++--------------
 gdb/probe.h         |  2 +-
 gdb/stap-probe.c    | 12 +++++++-----
 gdb/symfile-debug.c |  4 ++--
 gdb/symfile.h       |  3 ++-
 8 files changed, 64 insertions(+), 53 deletions(-)

diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index a51f35800ab..52973784e9a 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -81,7 +81,7 @@ public:
   bool is_linespec (const char **linespecp) const override;
 
   /* See probe.h.  */
-  void get_probes (std::vector<probe *> *probesp,
+  void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
 		   struct objfile *objfile) const override;
 
   /* See probe.h.  */
@@ -380,7 +380,7 @@ struct dtrace_dof_probe
 static void
 dtrace_process_dof_probe (struct objfile *objfile,
 			  struct gdbarch *gdbarch,
-			  std::vector<probe *> *probesp,
+			  std::vector<std::unique_ptr<probe>> *probesp,
 			  struct dtrace_dof_hdr *dof,
 			  struct dtrace_dof_probe *probe,
 			  struct dtrace_dof_provider *provider,
@@ -507,7 +507,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
 					    std::move (enablers_copy));
 
       /* Successfully created probe.  */
-      probesp->push_back (ret);
+      probesp->emplace_back (ret);
     }
 }
 
@@ -518,7 +518,8 @@ dtrace_process_dof_probe (struct objfile *objfile,
 
 static void
 dtrace_process_dof (asection *sect, struct objfile *objfile,
-		    std::vector<probe *> *probesp, struct dtrace_dof_hdr *dof)
+		    std::vector<std::unique_ptr<probe>> *probesp,
+		    struct dtrace_dof_hdr *dof)
 {
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
   struct dtrace_dof_sect *section;
@@ -833,8 +834,9 @@ dtrace_static_probe_ops::is_linespec (const char **linespecp) const
 /* Implementation of the get_probes method.  */
 
 void
-dtrace_static_probe_ops::get_probes (std::vector<probe *> *probesp,
-				     struct objfile *objfile) const
+dtrace_static_probe_ops::get_probes
+  (std::vector<std::unique_ptr<probe>> *probesp,
+   struct objfile *objfile) const
 {
   bfd *abfd = objfile->obfd;
   asection *sect = NULL;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 55a16bb2f8e..deee6f0baab 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -64,9 +64,13 @@ struct elfinfo
     asection *mdebugsect;	/* Section pointer for .mdebug section */
   };
 
+/* Type for per-BFD data.  */
+
+typedef std::vector<std::unique_ptr<probe>> elfread_data;
+
 /* Per-BFD data for probe info.  */
 
-static const struct bfd_data *probe_key = NULL;
+static const struct bfd_key<elfread_data> probe_key;
 
 /* Minimal symbols located at the GOT entries for .plt - that is the real
    pointer where the given entry will jump to.  It gets updated by the real
@@ -1347,43 +1351,24 @@ elf_symfile_init (struct objfile *objfile)
 
 /* Implementation of `sym_get_probes', as documented in symfile.h.  */
 
-static const std::vector<probe *> &
+static const elfread_data &
 elf_get_probes (struct objfile *objfile)
 {
-  std::vector<probe *> *probes_per_bfd;
-
-  /* Have we parsed this objfile's probes already?  */
-  probes_per_bfd = (std::vector<probe *> *) bfd_data (objfile->obfd, probe_key);
+  elfread_data *probes_per_bfd = probe_key.get (objfile->obfd);
 
   if (probes_per_bfd == NULL)
     {
-      probes_per_bfd = new std::vector<probe *>;
+      probes_per_bfd = probe_key.emplace (objfile->obfd);
 
       /* Here we try to gather information about all types of probes from the
 	 objfile.  */
       for (const static_probe_ops *ops : all_static_probe_ops)
 	ops->get_probes (probes_per_bfd, objfile);
-
-      set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
     }
 
   return *probes_per_bfd;
 }
 
-/* Helper function used to free the space allocated for storing SystemTap
-   probe information.  */
-
-static void
-probe_key_free (bfd *abfd, void *d)
-{
-  std::vector<probe *> *probes = (std::vector<probe *> *) d;
-
-  for (probe *p : *probes)
-    delete p;
-
-  delete probes;
-}
-
 \f
 
 /* Implementation `sym_probe_fns', as documented in symfile.h.  */
@@ -1475,7 +1460,6 @@ static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =
 void
 _initialize_elfread (void)
 {
-  probe_key = register_bfd_data_with_cleanup (NULL, probe_key_free);
   add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
 
   elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
diff --git a/gdb/probe.c b/gdb/probe.c
index b9337a9d19f..7bc75d8e879 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -47,7 +47,7 @@ public:
   bool is_linespec (const char **linespecp) const override;
 
   /* See probe.h.  */
-  void get_probes (std::vector<probe *> *probesp,
+  void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
 		   struct objfile *objfile) const override;
 
   /* See probe.h.  */
@@ -84,10 +84,10 @@ parse_probes_in_pspace (const static_probe_ops *spops,
 			   objfile_namestr) != 0)
 	continue;
 
-      const std::vector<probe *> &probes
+      const std::vector<std::unique_ptr<probe>> &probes
 	= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
 
-      for (probe *p : probes)
+      for (auto &p : probes)
 	{
 	  if (spops != &any_static_probe_ops && p->get_static_ops () != spops)
 	    continue;
@@ -103,7 +103,7 @@ parse_probes_in_pspace (const static_probe_ops *spops,
 	  sal.explicit_pc = 1;
 	  sal.section = find_pc_overlay (sal.pc);
 	  sal.pspace = search_pspace;
-	  sal.prob = p;
+	  sal.prob = p.get ();
 	  sal.objfile = objfile;
 
 	  result->push_back (std::move (sal));
@@ -223,9 +223,9 @@ find_probes_in_objfile (struct objfile *objfile, const char *provider,
   if (!objfile->sf || !objfile->sf->sym_probe_fns)
     return result;
 
-  const std::vector<probe *> &probes
+  const std::vector<std::unique_ptr<probe>> &probes
     = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
-  for (probe *p : probes)
+  for (auto &p : probes)
     {
       if (p->get_provider () != provider)
 	continue;
@@ -233,7 +233,7 @@ find_probes_in_objfile (struct objfile *objfile, const char *provider,
       if (p->get_name () != name)
 	continue;
 
-      result.push_back (p);
+      result.push_back (p.get ());
     }
 
   return result;
@@ -256,13 +256,13 @@ find_probe_by_pc (CORE_ADDR pc)
 	continue;
 
       /* If this proves too inefficient, we can replace with a hash.  */
-      const std::vector<probe *> &probes
+      const std::vector<std::unique_ptr<probe>> &probes
 	= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
-      for (probe *p : probes)
+      for (auto &p : probes)
 	if (p->get_relocated_address (objfile) == pc)
 	  {
 	    result.objfile = objfile;
-	    result.prob = p;
+	    result.prob = p.get ();
 	    return result;
 	  }
     }
@@ -305,10 +305,10 @@ collect_probes (const std::string &objname, const std::string &provider,
 	    continue;
 	}
 
-      const std::vector<probe *> &probes
+      const std::vector<std::unique_ptr<probe>> &probes
 	= objfile->sf->sym_probe_fns->sym_get_probes (objfile);
 
-      for (probe *p : probes)
+      for (auto &p : probes)
 	{
 	  if (spops != &any_static_probe_ops && p->get_static_ops () != spops)
 	    continue;
@@ -321,7 +321,7 @@ collect_probes (const std::string &objname, const std::string &provider,
 	      && probe_pat->exec (p->get_name ().c_str (), 0, NULL, 0) != 0)
 	    continue;
 
-	  result.emplace_back (p, objfile);
+	  result.emplace_back (p.get (), objfile);
 	}
     }
 
@@ -750,7 +750,7 @@ any_static_probe_ops::is_linespec (const char **linespecp) const
 /* Implementation of 'get_probes' method.  */
 
 void
-any_static_probe_ops::get_probes (std::vector<probe *> *probesp,
+any_static_probe_ops::get_probes (std::vector<std::unique_ptr<probe>> *probesp,
 				  struct objfile *objfile) const
 {
   /* No probes can be provided by this dummy backend.  */
diff --git a/gdb/probe.h b/gdb/probe.h
index 2f665e3a658..5c83f494714 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -62,7 +62,7 @@ public:
   virtual bool is_linespec (const char **linespecp) const = 0;
 
   /* Function that should fill PROBES with known probes from OBJFILE.  */
-  virtual void get_probes (std::vector<probe *> *probes,
+  virtual void get_probes (std::vector<std::unique_ptr<probe>> *probes,
 			    struct objfile *objfile) const = 0;
 
   /* Return a pointer to a name identifying the probe type.  This is
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 24b2b78a903..e70940c4878 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -106,7 +106,7 @@ public:
   bool is_linespec (const char **linespecp) const override;
 
   /* See probe.h.  */
-  void get_probes (std::vector<probe *> *probesp,
+  void get_probes (std::vector<std::unique_ptr<probe>> *probesp,
 		   struct objfile *objfile) const override;
 
   /* See probe.h.  */
@@ -1497,7 +1497,8 @@ stap_probe::gen_info_probes_table_values () const
 
 static void
 handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
-		   std::vector<probe *> *probesp, CORE_ADDR base)
+		   std::vector<std::unique_ptr<probe>> *probesp,
+		   CORE_ADDR base)
 {
   bfd *abfd = objfile->obfd;
   int size = bfd_get_arch_size (abfd) / 8;
@@ -1561,7 +1562,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
 				    address, gdbarch, sem_addr, probe_args);
 
   /* Successfully created probe.  */
-  probesp->push_back (ret);
+  probesp->emplace_back (ret);
 }
 
 /* Helper function which tries to find the base address of the SystemTap
@@ -1615,8 +1616,9 @@ stap_static_probe_ops::is_linespec (const char **linespecp) const
 /* Implementation of the 'get_probes' method.  */
 
 void
-stap_static_probe_ops::get_probes (std::vector<probe *> *probesp,
-				   struct objfile *objfile) const
+stap_static_probe_ops::get_probes
+  (std::vector<std::unique_ptr<probe>> *probesp,
+   struct objfile *objfile) const
 {
   /* If we are here, then this is the first time we are parsing the
      SystemTap probe's information.  We basically have to count how many
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 8266ecbabf0..0f9da66e536 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -382,13 +382,13 @@ static const struct quick_symbol_functions debug_sym_quick_functions =
 \f
 /* Debugging version of struct sym_probe_fns.  */
 
-static const std::vector<probe *> &
+static const std::vector<std::unique_ptr<probe>> &
 debug_sym_get_probes (struct objfile *objfile)
 {
   const struct debug_sym_fns_data *debug_data
     = symfile_debug_objfile_data_key.get (objfile);
 
-  const std::vector<probe *> &retval
+  const std::vector<std::unique_ptr<probe>> &retval
     = debug_data->real_sf->sym_probe_fns->sym_get_probes (objfile);
 
   fprintf_filtered (gdb_stdlog,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index a873dfe9451..daddd2e21ab 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -292,7 +292,8 @@ struct quick_symbol_functions
 struct sym_probe_fns
 {
   /* If non-NULL, return a reference to vector of probe objects.  */
-  const std::vector<probe *> &(*sym_get_probes) (struct objfile *);
+  const std::vector<std::unique_ptr<probe>> &(*sym_get_probes)
+    (struct objfile *);
 };
 
 /* Structure to keep track of symbol reading functions for various
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 05/31] Convert inflow to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 16/31] Convert xcoffread.c to type-safe registry API Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 04/31] Convert target dcache " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 07/31] Convert objfiles.c " Tom Tromey
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes inflow.c to use the type-safe registry API.  This fixes a
latent bug in swap_terminal_info, which previously said:

  terminal_info *info_a
    = (terminal_info *) inferior_data (a, inflow_inferior_data);
  terminal_info *info_b
    = (terminal_info *) inferior_data (a, inflow_inferior_data);

... both of which examine 'a'.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* inflow.c (struct terminal_info): Add destructor and
	initializers.
	(inflow_inferior_data): Change type.
	(~terminal_info): Rename from inflow_inferior_data_cleanup.
	(get_inflow_inferior_data, inflow_inferior_exit)
	(swap_terminal_info, _initialize_inflow): Update.
---
 gdb/ChangeLog |  9 +++++++++
 gdb/inflow.c  | 55 +++++++++++++++++----------------------------------
 2 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/gdb/inflow.c b/gdb/inflow.c
index b71511308b3..339b55c0bc6 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -58,13 +58,16 @@ static struct serial *stdin_serial;
    the inferior is resumed in the foreground.  */
 struct terminal_info
 {
+  terminal_info () = default;
+  ~terminal_info ();
+
   /* The name of the tty (from the `tty' command) that we gave to the
      inferior when it was started.  */
-  char *run_terminal;
+  char *run_terminal = nullptr;
 
   /* TTY state.  We save it whenever the inferior stops, and restore
      it when it resumes in the foreground.  */
-  serial_ttystate ttystate;
+  serial_ttystate ttystate {};
 
 #ifdef HAVE_TERMIOS_H
   /* The terminal's foreground process group.  Saved whenever the
@@ -80,11 +83,11 @@ struct terminal_info
      inf2's pgrp in the foreground instead of inf1's (which would be
      problematic since it would be left stopped: Ctrl-C wouldn't work,
      for example).  */
-  pid_t process_group;
+  pid_t process_group = 0;
 #endif
 
   /* fcntl flags.  Saved and restored just like ttystate.  */
-  int tflags;
+  int tflags = 0;
 };
 
 /* Our own tty state, which we restore every time we need to deal with
@@ -623,16 +626,12 @@ child_pass_ctrlc (struct target_ops *self)
 }
 
 /* Per-inferior data key.  */
-static const struct inferior_data *inflow_inferior_data;
+static const struct inferior_key<terminal_info> inflow_inferior_data;
 
-static void
-inflow_inferior_data_cleanup (struct inferior *inf, void *arg)
+terminal_info::~terminal_info ()
 {
-  struct terminal_info *info = (struct terminal_info *) arg;
-
-  xfree (info->run_terminal);
-  xfree (info->ttystate);
-  xfree (info);
+  xfree (run_terminal);
+  xfree (ttystate);
 }
 
 /* Get the current svr4 data.  If none is found yet, add it now.  This
@@ -643,12 +642,9 @@ get_inflow_inferior_data (struct inferior *inf)
 {
   struct terminal_info *info;
 
-  info = (struct terminal_info *) inferior_data (inf, inflow_inferior_data);
+  info = inflow_inferior_data.get (inf);
   if (info == NULL)
-    {
-      info = XCNEW (struct terminal_info);
-      set_inferior_data (inf, inflow_inferior_data, info);
-    }
+    info = inflow_inferior_data.emplace (inf);
 
   return info;
 }
@@ -662,18 +658,8 @@ get_inflow_inferior_data (struct inferior *inf)
 static void
 inflow_inferior_exit (struct inferior *inf)
 {
-  struct terminal_info *info;
-
   inf->terminal_state = target_terminal_state::is_ours;
-
-  info = (struct terminal_info *) inferior_data (inf, inflow_inferior_data);
-  if (info != NULL)
-    {
-      xfree (info->run_terminal);
-      xfree (info->ttystate);
-      xfree (info);
-      set_inferior_data (inf, inflow_inferior_data, NULL);
-    }
+  inflow_inferior_data.clear (inf);
 }
 
 void
@@ -705,13 +691,11 @@ copy_terminal_info (struct inferior *to, struct inferior *from)
 void
 swap_terminal_info (inferior *a, inferior *b)
 {
-  terminal_info *info_a
-    = (terminal_info *) inferior_data (a, inflow_inferior_data);
-  terminal_info *info_b
-    = (terminal_info *) inferior_data (a, inflow_inferior_data);
+  terminal_info *info_a = inflow_inferior_data.get (a);
+  terminal_info *info_b = inflow_inferior_data.get (b);
 
-  set_inferior_data (a, inflow_inferior_data, info_b);
-  set_inferior_data (b, inflow_inferior_data, info_a);
+  inflow_inferior_data.set (a, info_b);
+  inflow_inferior_data.set (b, info_a);
 
   std::swap (a->terminal_state, b->terminal_state);
 }
@@ -1006,7 +990,4 @@ _initialize_inflow (void)
   have_job_control ();
 
   gdb::observers::inferior_exit.attach (inflow_inferior_exit);
-
-  inflow_inferior_data
-    = register_inferior_data_with_cleanup (NULL, inflow_inferior_data_cleanup);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 06/31] Convert break-catch-syscall.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (8 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 19/31] Convert fbsd-tdep.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 03/31] Convert symbol_cache " Tom Tromey
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes break-catch-syscall.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* break-catch-syscall.c (catch_syscall_inferior_data): Move.
	Change type.
	(get_catch_syscall_inferior_data): Update.
	(catch_syscall_inferior_data_cleanup): Remove.
	(_initialize_break_catch_syscall): Update.
---
 gdb/ChangeLog             |  8 ++++++++
 gdb/break-catch-syscall.c | 25 +++++--------------------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 6a911fbc2a3..cd4870f7f51 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -42,8 +42,6 @@ struct syscall_catchpoint : public breakpoint
   std::vector<int> syscalls_to_be_caught;
 };
 
-static const struct inferior_data *catch_syscall_inferior_data = NULL;
-
 struct catch_syscall_inferior_data
 {
   /* We keep a count of the number of times the user has requested a
@@ -61,31 +59,21 @@ struct catch_syscall_inferior_data
   int total_syscalls_count;
 };
 
+static const struct inferior_key<struct catch_syscall_inferior_data>
+  catch_syscall_inferior_data;
+
 static struct catch_syscall_inferior_data *
 get_catch_syscall_inferior_data (struct inferior *inf)
 {
   struct catch_syscall_inferior_data *inf_data;
 
-  inf_data = ((struct catch_syscall_inferior_data *)
-	      inferior_data (inf, catch_syscall_inferior_data));
+  inf_data = catch_syscall_inferior_data.get (inf);
   if (inf_data == NULL)
-    {
-      inf_data = new struct catch_syscall_inferior_data ();
-      set_inferior_data (inf, catch_syscall_inferior_data, inf_data);
-    }
+    inf_data = catch_syscall_inferior_data.emplace (inf);
 
   return inf_data;
 }
 
-static void
-catch_syscall_inferior_data_cleanup (struct inferior *inf, void *arg)
-{
-  struct catch_syscall_inferior_data *inf_data
-    = (struct catch_syscall_inferior_data *) arg;
-  delete inf_data;
-}
-
-
 /* Implement the "insert" breakpoint_ops method for syscall
    catchpoints.  */
 
@@ -617,9 +605,6 @@ _initialize_break_catch_syscall (void)
   initialize_syscall_catchpoint_ops ();
 
   gdb::observers::inferior_exit.attach (clear_syscall_counts);
-  catch_syscall_inferior_data
-    = register_inferior_data_with_cleanup (NULL,
-					   catch_syscall_inferior_data_cleanup);
 
   add_catch_command ("syscall", _("\
 Catch system calls by their names, groups and/or numbers.\n\
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 03/31] Convert symbol_cache to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (9 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 06/31] Convert break-catch-syscall.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 17/31] Convert probes " Tom Tromey
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the symbol_cache to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* symtab.c (struct symbol_cache): Add destructor and
	initializers.
	(symbol_cache_key): Move.  Change type.
	(make_symbol_cache, free_symbol_cache): Remove.
	(get_symbol_cache): Update.
	(symbol_cache_cleanup): Remove.
	(ALL_PSPACES, symbol_cache_flush)
	(maintenance_print_symbol_cache)
	(maintenance_print_symbol_cache_statistics, _initialize_symtab):
	Update.
---
 gdb/ChangeLog | 13 +++++++++
 gdb/symtab.c  | 75 +++++++++++++++------------------------------------
 2 files changed, 34 insertions(+), 54 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index cf97a1d18e2..2e5fbbedde2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -119,10 +119,6 @@ struct main_info
 
 static const program_space_key<main_info> main_progspace_key;
 
-/* Program space key for finding its symbol cache.  */
-
-static const struct program_space_data *symbol_cache_key;
-
 /* The default symbol cache size.
    There is no extra cpu cost for large N (except when flushing the cache,
    which is rare).  The value here is just a first attempt.  A better default
@@ -214,10 +210,22 @@ struct block_symbol_cache
 
 struct symbol_cache
 {
-  struct block_symbol_cache *global_symbols;
-  struct block_symbol_cache *static_symbols;
+  symbol_cache () = default;
+
+  ~symbol_cache ()
+  {
+    xfree (global_symbols);
+    xfree (static_symbols);
+  }
+
+  struct block_symbol_cache *global_symbols = nullptr;
+  struct block_symbol_cache *static_symbols = nullptr;
 };
 
+/* Program space key for finding its symbol cache.  */
+
+static const program_space_key<symbol_cache> symbol_cache_key;
+
 /* When non-zero, print debugging messages related to symtab creation.  */
 unsigned int symtab_create_debug = 0;
 
@@ -1226,57 +1234,23 @@ resize_symbol_cache (struct symbol_cache *cache, unsigned int new_size)
     }
 }
 
-/* Make a symbol cache of size SIZE.  */
-
-static struct symbol_cache *
-make_symbol_cache (unsigned int size)
-{
-  struct symbol_cache *cache;
-
-  cache = XCNEW (struct symbol_cache);
-  resize_symbol_cache (cache, symbol_cache_size);
-  return cache;
-}
-
-/* Free the space used by CACHE.  */
-
-static void
-free_symbol_cache (struct symbol_cache *cache)
-{
-  xfree (cache->global_symbols);
-  xfree (cache->static_symbols);
-  xfree (cache);
-}
-
 /* Return the symbol cache of PSPACE.
    Create one if it doesn't exist yet.  */
 
 static struct symbol_cache *
 get_symbol_cache (struct program_space *pspace)
 {
-  struct symbol_cache *cache
-    = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
+  struct symbol_cache *cache = symbol_cache_key.get (pspace);
 
   if (cache == NULL)
     {
-      cache = make_symbol_cache (symbol_cache_size);
-      set_program_space_data (pspace, symbol_cache_key, cache);
+      cache = symbol_cache_key.emplace (pspace);
+      resize_symbol_cache (cache, symbol_cache_size);
     }
 
   return cache;
 }
 
-/* Delete the symbol cache of PSPACE.
-   Called when PSPACE is destroyed.  */
-
-static void
-symbol_cache_cleanup (struct program_space *pspace, void *data)
-{
-  struct symbol_cache *cache = (struct symbol_cache *) data;
-
-  free_symbol_cache (cache);
-}
-
 /* Set the size of the symbol cache in all program spaces.  */
 
 static void
@@ -1286,8 +1260,7 @@ set_symbol_cache_size (unsigned int new_size)
 
   ALL_PSPACES (pspace)
     {
-      struct symbol_cache *cache
-	= (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
+      struct symbol_cache *cache = symbol_cache_key.get (pspace);
 
       /* The pspace could have been created but not have a cache yet.  */
       if (cache != NULL)
@@ -1443,8 +1416,7 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
 static void
 symbol_cache_flush (struct program_space *pspace)
 {
-  struct symbol_cache *cache
-    = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
+  struct symbol_cache *cache = symbol_cache_key.get (pspace);
   int pass;
 
   if (cache == NULL)
@@ -1558,8 +1530,7 @@ maintenance_print_symbol_cache (const char *args, int from_tty)
 		       : "(no object file)");
 
       /* If the cache hasn't been created yet, avoid creating one.  */
-      cache
-	= (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
+      cache = symbol_cache_key.get (pspace);
       if (cache == NULL)
 	printf_filtered ("  <empty>\n");
       else
@@ -1630,8 +1601,7 @@ maintenance_print_symbol_cache_statistics (const char *args, int from_tty)
 		       : "(no object file)");
 
       /* If the cache hasn't been created yet, avoid creating one.  */
-      cache
-	= (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
+      cache = symbol_cache_key.get (pspace);
       if (cache == NULL)
  	printf_filtered ("  empty, no stats available\n");
       else
@@ -6037,9 +6007,6 @@ _initialize_symtab (void)
 {
   initialize_ordinary_address_classes ();
 
-  symbol_cache_key
-    = register_program_space_data_with_cleanup (NULL, symbol_cache_cleanup);
-
   add_info ("variables", info_variables_command,
 	    info_print_args_help (_("\
 All global and static variable names or those matching REGEXPs.\n\
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 12/31] Convert linux-tdep.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (11 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 17/31] Convert probes " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 08/31] Convert auto-load.c " Tom Tromey
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes linux-tdep.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* linux-tdep.c (struct linux_info): Add initializers.
	(linux_inferior_data): Move.  Change type.
	(invalidate_linux_cache_inf): Update.
	(linux_inferior_data_cleanup): Remove.
	(get_linux_inferior_data, _initialize_linux_tdep): Update.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/linux-tdep.c | 39 ++++++++-------------------------------
 2 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index c1666d189ae..f32631f4acb 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -183,9 +183,6 @@ get_linux_gdbarch_data (struct gdbarch *gdbarch)
 	  gdbarch_data (gdbarch, linux_gdbarch_data_handle));
 }
 
-/* Per-inferior data key.  */
-static const struct inferior_data *linux_inferior_data;
-
 /* Linux-specific cached data.  This is used by GDB for caching
    purposes for each inferior.  This helps reduce the overhead of
    transfering data from a remote target to the local host.  */
@@ -196,38 +193,24 @@ struct linux_info
      at this info requires an auxv lookup (which is itself cached),
      and looking through the inferior's mappings (which change
      throughout execution and therefore cannot be cached).  */
-  struct mem_range vsyscall_range;
+  struct mem_range vsyscall_range {};
 
   /* Zero if we haven't tried looking up the vsyscall's range before
      yet.  Positive if we tried looking it up, and found it.  Negative
      if we tried looking it up but failed.  */
-  int vsyscall_range_p;
+  int vsyscall_range_p = 0;
 };
 
+/* Per-inferior data key.  */
+static const struct inferior_key<linux_info> linux_inferior_data;
+
 /* Frees whatever allocated space there is to be freed and sets INF's
    linux cache data pointer to NULL.  */
 
 static void
 invalidate_linux_cache_inf (struct inferior *inf)
 {
-  struct linux_info *info;
-
-  info = (struct linux_info *) inferior_data (inf, linux_inferior_data);
-  if (info != NULL)
-    {
-      xfree (info);
-      set_inferior_data (inf, linux_inferior_data, NULL);
-    }
-}
-
-/* Handles the cleanup of the linux cache for inferior INF.  ARG is
-   ignored.  Callback for the inferior_appeared and inferior_exit
-   events.  */
-
-static void
-linux_inferior_data_cleanup (struct inferior *inf, void *arg)
-{
-  invalidate_linux_cache_inf (inf);
+  linux_inferior_data.clear (inf);
 }
 
 /* Fetch the linux cache info for INF.  This function always returns a
@@ -239,12 +222,9 @@ get_linux_inferior_data (void)
   struct linux_info *info;
   struct inferior *inf = current_inferior ();
 
-  info = (struct linux_info *) inferior_data (inf, linux_inferior_data);
+  info = linux_inferior_data.get (inf);
   if (info == NULL)
-    {
-      info = XCNEW (struct linux_info);
-      set_inferior_data (inf, linux_inferior_data, info);
-    }
+    info = linux_inferior_data.emplace (inf);
 
   return info;
 }
@@ -2582,9 +2562,6 @@ _initialize_linux_tdep (void)
   linux_gdbarch_data_handle =
     gdbarch_data_register_post_init (init_linux_gdbarch_data);
 
-  /* Set a cache per-inferior.  */
-  linux_inferior_data
-    = register_inferior_data_with_cleanup (NULL, linux_inferior_data_cleanup);
   /* Observers used to invalidate the cache when needed.  */
   gdb::observers::inferior_exit.attach (invalidate_linux_cache_inf);
   gdb::observers::inferior_appeared.attach (invalidate_linux_cache_inf);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 00/31] Add a type-safe API to registries
@ 2019-05-03 23:12 Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 16/31] Convert xcoffread.c to type-safe registry API Tom Tromey
                   ` (30 more replies)
  0 siblings, 31 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches

This is v2 of my series to add a type-safe API to the registry
feature.

v1 was here: https://sourceware.org/ml/gdb-patches/2019-04/msg00436.html

Compared to v1, this version:

* Changes the "emplace" method so that it is only visible when the
  deleter is std::default_deleter.

* Adds a "clear" method to simplify some common code sequences.

* Converts many more (but still not all) modules to use the new API.

Tested by the buildbot.

Tom


^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 19/31] Convert fbsd-tdep.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (7 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 15/31] Convert solib-svr4.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-06 20:56   ` John Baldwin
  2019-05-03 23:12 ` [PATCH v2 06/31] Convert break-catch-syscall.c " Tom Tromey
                   ` (21 subsequent siblings)
  30 siblings, 1 reply; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes fbsd-tdep.c to use the type-safe registry API.

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

	* fbsd-tdep.c (struct fbsd_pspace_data): Add initializers.
	(fbsd_pspace_data_handle): Move lower.  Change type.
	(get_fbsd_pspace_data): Update.
	(fbsd_pspace_data_cleanup): Remove.
	(_initialize_fbsd_tdep): Update.
---
 gdb/ChangeLog   |  8 ++++++++
 gdb/fbsd-tdep.c | 31 +++++++++----------------------
 2 files changed, 17 insertions(+), 22 deletions(-)

diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 4efa0f7ae11..cc7c2b7ab2f 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -445,41 +445,30 @@ get_fbsd_gdbarch_data (struct gdbarch *gdbarch)
 	  gdbarch_data (gdbarch, fbsd_gdbarch_data_handle));
 }
 
-/* Per-program-space data for FreeBSD architectures.  */
-static const struct program_space_data *fbsd_pspace_data_handle;
-
 struct fbsd_pspace_data
 {
   /* Offsets in the runtime linker's 'Obj_Entry' structure.  */
-  LONGEST off_linkmap;
-  LONGEST off_tlsindex;
-  bool rtld_offsets_valid;
+  LONGEST off_linkmap = 0;
+  LONGEST off_tlsindex = 0;
+  bool rtld_offsets_valid = false;
 };
 
+/* Per-program-space data for FreeBSD architectures.  */
+static const struct program_space_key<fbsd_pspace_data>
+  fbsd_pspace_data_handle;
+
 static struct fbsd_pspace_data *
 get_fbsd_pspace_data (struct program_space *pspace)
 {
   struct fbsd_pspace_data *data;
 
-  data = ((struct fbsd_pspace_data *)
-	  program_space_data (pspace, fbsd_pspace_data_handle));
+  data = fbsd_pspace_data_handle.get (pspace);
   if (data == NULL)
-    {
-      data = XCNEW (struct fbsd_pspace_data);
-      set_program_space_data (pspace, fbsd_pspace_data_handle, data);
-    }
+    data = fbsd_pspace_data_handle.emplace (pspace);
 
   return data;
 }
 
-/* The cleanup callback for FreeBSD architecture per-program-space data.  */
-
-static void
-fbsd_pspace_data_cleanup (struct program_space *pspace, void *data)
-{
-  xfree (data);
-}
-
 /* This is how we want PTIDs from core files to be printed.  */
 
 static std::string
@@ -2100,6 +2089,4 @@ _initialize_fbsd_tdep (void)
 {
   fbsd_gdbarch_data_handle =
     gdbarch_data_register_post_init (init_fbsd_gdbarch_data);
-  fbsd_pspace_data_handle
-    = register_program_space_data_with_cleanup (NULL, fbsd_pspace_data_cleanup);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 08/31] Convert auto-load.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (12 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 12/31] Convert linux-tdep.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 10/31] Convert symfile-debug.c " Tom Tromey
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes auto-load.c to use the type-safe registry API.  It also
changes a couple of types to "bool", removing uses of "FALSE".

2019-04-22  Tom Tromey  <tom@tromey.com>

	* auto-load.c (struct auto_load_pspace_info): Add destructor and
	initializers.
	<unsupported_script_warning_printed,
	script_not_found_warning_printed>: Now bool.
	(auto_load_pspace_data): Change type.
	(~auto_load_pspace_info): Rename from
	auto_load_pspace_data_cleanup.
	(get_auto_load_pspace_data, init_loaded_scripts_info)
	(clear_section_scripts, maybe_print_unsupported_script_warning)
	(maybe_print_script_not_found_warning, _initialize_auto_load):
	Update.
---
 gdb/ChangeLog   | 14 ++++++++++++
 gdb/auto-load.c | 60 ++++++++++++++++++-------------------------------
 2 files changed, 36 insertions(+), 38 deletions(-)

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index ae7a189dc04..6833c21323a 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -527,18 +527,21 @@ For more information about this security protection see the\n\
 
 struct auto_load_pspace_info
 {
+  auto_load_pspace_info () = default;
+  ~auto_load_pspace_info ();
+
   /* For each program space we keep track of loaded scripts, both when
      specified as file names and as scripts to be executed directly.  */
-  struct htab *loaded_script_files;
-  struct htab *loaded_script_texts;
+  struct htab *loaded_script_files = nullptr;
+  struct htab *loaded_script_texts = nullptr;
 
   /* Non-zero if we've issued the warning about an auto-load script not being
      supported.  We only want to issue this warning once.  */
-  int unsupported_script_warning_printed;
+  bool unsupported_script_warning_printed = false;
 
   /* Non-zero if we've issued the warning about an auto-load script not being
      found.  We only want to issue this warning once.  */
-  int script_not_found_warning_printed;
+  bool script_not_found_warning_printed = false;
 };
 
 /* Objects of this type are stored in the loaded_script hash table.  */
@@ -559,18 +562,15 @@ struct loaded_script
 };
 
 /* Per-program-space data key.  */
-static const struct program_space_data *auto_load_pspace_data;
+static const struct program_space_key<struct auto_load_pspace_info>
+  auto_load_pspace_data;
 
-static void
-auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg)
+auto_load_pspace_info::~auto_load_pspace_info ()
 {
-  struct auto_load_pspace_info *info = (struct auto_load_pspace_info *) arg;
-
-  if (info->loaded_script_files)
-    htab_delete (info->loaded_script_files);
-  if (info->loaded_script_texts)
-    htab_delete (info->loaded_script_texts);
-  xfree (info);
+  if (loaded_script_files)
+    htab_delete (loaded_script_files);
+  if (loaded_script_texts)
+    htab_delete (loaded_script_texts);
 }
 
 /* Get the current autoload data.  If none is found yet, add it now.  This
@@ -581,13 +581,9 @@ get_auto_load_pspace_data (struct program_space *pspace)
 {
   struct auto_load_pspace_info *info;
 
-  info = ((struct auto_load_pspace_info *)
-	  program_space_data (pspace, auto_load_pspace_data));
+  info = auto_load_pspace_data.get (pspace);
   if (info == NULL)
-    {
-      info = XCNEW (struct auto_load_pspace_info);
-      set_program_space_data (pspace, auto_load_pspace_data, info);
-    }
+    info = auto_load_pspace_data.emplace (pspace);
 
   return info;
 }
@@ -632,8 +628,8 @@ init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info)
 						  eq_loaded_script_entry,
 						  xfree);
 
-  pspace_info->unsupported_script_warning_printed = FALSE;
-  pspace_info->script_not_found_warning_printed = FALSE;
+  pspace_info->unsupported_script_warning_printed = false;
+  pspace_info->script_not_found_warning_printed = false;
 }
 
 /* Wrapper on get_auto_load_pspace_data to also allocate the hash table
@@ -747,17 +743,9 @@ clear_section_scripts (void)
   struct program_space *pspace = current_program_space;
   struct auto_load_pspace_info *info;
 
-  info = ((struct auto_load_pspace_info *)
-	  program_space_data (pspace, auto_load_pspace_data));
+  info = auto_load_pspace_data.get (pspace);
   if (info != NULL && info->loaded_script_files != NULL)
-    {
-      htab_delete (info->loaded_script_files);
-      htab_delete (info->loaded_script_texts);
-      info->loaded_script_files = NULL;
-      info->loaded_script_texts = NULL;
-      info->unsupported_script_warning_printed = FALSE;
-      info->script_not_found_warning_printed = FALSE;
-    }
+    auto_load_pspace_data.clear (pspace);
 }
 
 /* Look for the auto-load script in LANGUAGE associated with OBJFILE where
@@ -1386,7 +1374,7 @@ of file %s.\n\
 Use `info auto-load %s-scripts [REGEXP]' to list them."),
 	       offset, section_name, objfile_name (objfile),
 	       ext_lang_name (language));
-      pspace_info->unsupported_script_warning_printed = 1;
+      pspace_info->unsupported_script_warning_printed = true;
     }
 }
 
@@ -1408,7 +1396,7 @@ of file %s.\n\
 Use `info auto-load %s-scripts [REGEXP]' to list them."),
 	       offset, section_name, objfile_name (objfile),
 	       ext_lang_name (language));
-      pspace_info->script_not_found_warning_printed = 1;
+      pspace_info->script_not_found_warning_printed = true;
     }
 }
 
@@ -1538,10 +1526,6 @@ _initialize_auto_load (void)
   char *guile_name_help;
   const char *suffix;
 
-  auto_load_pspace_data
-    = register_program_space_data_with_cleanup (NULL,
-						auto_load_pspace_data_cleanup);
-
   gdb::observers::new_objfile.attach (auto_load_new_objfile);
 
   add_setshow_boolean_cmd ("gdb-scripts", class_support,
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 13/31] Convert breakpoint.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (5 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 21/31] Convert ada-lang.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 15/31] Convert solib-svr4.c " Tom Tromey
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes breakpoint.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* breakpoint.c (breakpoint_objfile_key): Change type.
	(get_breakpoint_objfile_data): Update.
	(free_breakpoint_objfile_data): Remove.
	(_initialize_breakpoint): Update.
---
 gdb/ChangeLog    |  7 +++++++
 gdb/breakpoint.c | 23 ++++-------------------
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f6d2f36d0a4..35da97bd041 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3156,7 +3156,8 @@ struct breakpoint_objfile_data
   std::vector<probe *> exception_probes;
 };
 
-static const struct objfile_data *breakpoint_objfile_key;
+static const struct objfile_key<breakpoint_objfile_data>
+  breakpoint_objfile_key;
 
 /* Minimal symbol not found sentinel.  */
 static struct minimal_symbol msym_not_found;
@@ -3177,25 +3178,12 @@ get_breakpoint_objfile_data (struct objfile *objfile)
 {
   struct breakpoint_objfile_data *bp_objfile_data;
 
-  bp_objfile_data = ((struct breakpoint_objfile_data *)
-		     objfile_data (objfile, breakpoint_objfile_key));
+  bp_objfile_data = breakpoint_objfile_key.get (objfile);
   if (bp_objfile_data == NULL)
-    {
-      bp_objfile_data = new breakpoint_objfile_data ();
-      set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
-    }
+    bp_objfile_data = breakpoint_objfile_key.emplace (objfile);
   return bp_objfile_data;
 }
 
-static void
-free_breakpoint_objfile_data (struct objfile *obj, void *data)
-{
-  struct breakpoint_objfile_data *bp_objfile_data
-    = (struct breakpoint_objfile_data *) data;
-
-  delete bp_objfile_data;
-}
-
 static void
 create_overlay_event_breakpoint (void)
 {
@@ -15448,9 +15436,6 @@ _initialize_breakpoint (void)
   gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile);
   gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change);
 
-  breakpoint_objfile_key
-    = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data);
-
   breakpoint_chain = 0;
   /* Don't bother to call set_breakpoint_count.  $bpnum isn't useful
      before a breakpoint is set.  */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 23/31] Add a noop deleter
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (17 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 18/31] Convert ada-tasks.c " Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 01/31] Add a type-safe C++ interface to a registry Tom Tromey
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds a no-op deleter, which is used in subsequent patches.

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

	* common/gdb_unique_ptr.h (struct noop_deleter): New.
---
 gdb/ChangeLog               | 4 ++++
 gdb/common/gdb_unique_ptr.h | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/common/gdb_unique_ptr.h b/gdb/common/gdb_unique_ptr.h
index 327e1279296..a4be2bb7963 100644
--- a/gdb/common/gdb_unique_ptr.h
+++ b/gdb/common/gdb_unique_ptr.h
@@ -47,6 +47,13 @@ struct xfree_deleter<T[]>
 template<typename T> using unique_xmalloc_ptr
   = std::unique_ptr<T, xfree_deleter<T>>;
 
+/* A no-op deleter.  */
+template<typename T>
+struct noop_deleter
+{
+  void operator() (T *ptr) const { }
+};
+
 } /* namespace gdb */
 
 #endif /* COMMON_GDB_UNIQUE_PTR_H */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 04/31] Convert target dcache to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 16/31] Convert xcoffread.c to type-safe registry API Tom Tromey
@ 2019-05-03 23:12 ` Tom Tromey
  2019-05-03 23:12 ` [PATCH v2 05/31] Convert inflow " Tom Tromey
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the target dcache to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* target-dcache.c (target_dcache_cleanup): Remove.
	(target_dcache_aspace_key): Change type.
	(target_dcache_init_p, target_dcache_invalidate)
	(target_dcache_get, target_dcache_get_or_init)
	(_initialize_target_dcache): Update.
	* dcache.h (struct dcache_deleter): New.
---
 gdb/ChangeLog       |  9 +++++++++
 gdb/dcache.h        |  9 +++++++++
 gdb/target-dcache.c | 34 +++++++---------------------------
 3 files changed, 25 insertions(+), 27 deletions(-)

diff --git a/gdb/dcache.h b/gdb/dcache.h
index 9c29074c919..a58ac840d12 100644
--- a/gdb/dcache.h
+++ b/gdb/dcache.h
@@ -34,6 +34,15 @@ DCACHE *dcache_init (void);
 /* Free a DCACHE.  */
 void dcache_free (DCACHE *);
 
+/* A deletion adapter that calls dcache_free.  */
+struct dcache_deleter
+{
+  void operator() (DCACHE *d) const
+  {
+    dcache_free (d);
+  }
+};
+
 enum target_xfer_status
   dcache_read_memory_partial (struct target_ops *ops, DCACHE *dcache,
 			      CORE_ADDR memaddr, gdb_byte *myaddr,
diff --git a/gdb/target-dcache.c b/gdb/target-dcache.c
index 3fab9845bc3..98d5c1f83b6 100644
--- a/gdb/target-dcache.c
+++ b/gdb/target-dcache.c
@@ -23,16 +23,8 @@
 /* The target dcache is kept per-address-space.  This key lets us
    associate the cache with the address space.  */
 
-static const struct address_space_data *target_dcache_aspace_key;
-
-/* Clean up dcache, represented by ARG, which is associated with
-   ASPACE.  */
-
-static void
-target_dcache_cleanup (struct address_space *aspace, void *arg)
-{
-  dcache_free ((DCACHE *) arg);
-}
+static const struct address_space_key<DCACHE, dcache_deleter>
+  target_dcache_aspace_key;
 
 /* Target dcache is initialized or not.  */
 
@@ -40,8 +32,7 @@ int
 target_dcache_init_p (void)
 {
   DCACHE *dcache
-    = (DCACHE *) address_space_data (current_program_space->aspace,
-				     target_dcache_aspace_key);
+    = target_dcache_aspace_key.get (current_program_space->aspace);
 
   return (dcache != NULL);
 }
@@ -52,8 +43,7 @@ void
 target_dcache_invalidate (void)
 {
   DCACHE *dcache
-    = (DCACHE *) address_space_data (current_program_space->aspace,
-				     target_dcache_aspace_key);
+    = target_dcache_aspace_key.get (current_program_space->aspace);
 
   if (dcache != NULL)
     dcache_invalidate (dcache);
@@ -65,11 +55,7 @@ target_dcache_invalidate (void)
 DCACHE *
 target_dcache_get (void)
 {
-  DCACHE *dcache
-    = (DCACHE *) address_space_data (current_program_space->aspace,
-				     target_dcache_aspace_key);
-
-  return dcache;
+  return target_dcache_aspace_key.get (current_program_space->aspace);
 }
 
 /* Return the target dcache.  If it is not initialized yet, initialize
@@ -79,14 +65,12 @@ DCACHE *
 target_dcache_get_or_init (void)
 {
   DCACHE *dcache
-    = (DCACHE *) address_space_data (current_program_space->aspace,
-				     target_dcache_aspace_key);
+    = target_dcache_aspace_key.get (current_program_space->aspace);
 
   if (dcache == NULL)
     {
       dcache = dcache_init ();
-      set_address_space_data (current_program_space->aspace,
-			      target_dcache_aspace_key, dcache);
+      target_dcache_aspace_key.set (current_program_space->aspace, dcache);
     }
 
   return dcache;
@@ -193,8 +177,4 @@ access is on."),
 			   set_code_cache,
 			   show_code_cache,
 			   &setlist, &showlist);
-
-  target_dcache_aspace_key
-    = register_address_space_data_with_cleanup (NULL,
-						target_dcache_cleanup);
 }
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 22/31] Convert nto-tdep.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (27 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 14/31] Convert remote.c " Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:31 ` [PATCH v2 30/31] Convert dwarf2-frame.c " Tom Tromey
  2019-05-03 23:31 ` [PATCH v2 31/31] Convert gdbtypes.c " Tom Tromey
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes nto-tdep.c to use the type-safe registry API.

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

	* nto-tdep.c (nto_inferior_data_reg): Change type.
	(nto_inferior_data): Update.
	(nto_inferior_data_cleanup, nto_new_inferior_data)
	(_initialize_nto_tdep): Remove.
	* nto-tdep.h (struct nto_inferior_data): Add initializers.
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/nto-tdep.c | 37 ++++---------------------------------
 gdb/nto-tdep.h |  4 ++--
 3 files changed, 14 insertions(+), 35 deletions(-)

diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 0caa55c2493..48e731acd05 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -51,7 +51,8 @@ static char default_nto_target[] = "";
 
 struct nto_target_ops current_nto_target;
 
-static const struct inferior_data *nto_inferior_data_reg;
+static const struct inferior_key<struct nto_inferior_data>
+  nto_inferior_data_reg;
 
 static char *
 nto_target (void)
@@ -498,25 +499,6 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf,
   return len_read;
 }
 
-/* Allocate new nto_inferior_data object.  */
-
-static struct nto_inferior_data *
-nto_new_inferior_data (void)
-{
-  struct nto_inferior_data *const inf_data
-    = XCNEW (struct nto_inferior_data);
-
-  return inf_data;
-}
-
-/* Free inferior data.  */
-
-static void
-nto_inferior_data_cleanup (struct inferior *const inf, void *const dat)
-{
-  xfree (dat);
-}
-
 /* Return nto_inferior_data for the given INFERIOR.  If not yet created,
    construct it.  */
 
@@ -528,20 +510,9 @@ nto_inferior_data (struct inferior *const inferior)
 
   gdb_assert (inf != NULL);
 
-  inf_data
-    = (struct nto_inferior_data *) inferior_data (inf, nto_inferior_data_reg);
+  inf_data = nto_inferior_data_reg.get (inf);
   if (inf_data == NULL)
-    {
-      set_inferior_data (inf, nto_inferior_data_reg,
-			 (inf_data = nto_new_inferior_data ()));
-    }
+    inf_data = nto_inferior_data_reg.emplace (inf);
 
   return inf_data;
 }
-
-void
-_initialize_nto_tdep (void)
-{
-  nto_inferior_data_reg
-    = register_inferior_data_with_cleanup (NULL, nto_inferior_data_cleanup);
-}
diff --git a/gdb/nto-tdep.h b/gdb/nto-tdep.h
index 5127ab3f9ed..2410a03a4a6 100644
--- a/gdb/nto-tdep.h
+++ b/gdb/nto-tdep.h
@@ -152,10 +152,10 @@ get_nto_thread_info (thread_info *thread)
 struct nto_inferior_data
 {
   /* Last stopped flags result from wait function */
-  unsigned int stopped_flags;
+  unsigned int stopped_flags = 0;
 
   /* Last known stopped PC */
-  CORE_ADDR stopped_pc;
+  CORE_ADDR stopped_pc = 0;
 };
 
 /* Generic functions in nto-tdep.c.  */
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 11/31] Convert auxv.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (23 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 29/31] Convert objc-lang.c " Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 27/31] Remove mips_pdr_data Tom Tromey
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes auxv.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* auxv.c (auxv_inferior_data): Move.  Change type.
	(auxv_inferior_data_cleanup): Remove.
	(invalidate_auxv_cache_inf): Rewrite.
	(get_auxv_inferior_data, _initialize_auxv): Update.
---
 gdb/ChangeLog |  7 +++++++
 gdb/auxv.c    | 35 +++++------------------------------
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index 13caa936651..5e0ff26ab1a 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -293,9 +293,6 @@ target_auxv_parse (gdb_byte **readptr,
 }
 
 
-/* Per-inferior data key for auxv.  */
-static const struct inferior_data *auxv_inferior_data;
-
 /*  Auxiliary Vector information structure.  This is used by GDB
     for caching purposes for each inferior.  This helps reduce the
     overhead of transfering data from a remote target to the local host.  */
@@ -304,32 +301,15 @@ struct auxv_info
   gdb::optional<gdb::byte_vector> data;
 };
 
-/* Handles the cleanup of the auxv cache for inferior INF.  ARG is ignored.
-   Frees whatever allocated space there is to be freed and sets INF's auxv cache
-   data pointer to NULL.
-
-   This function is called when the following events occur: inferior_appeared,
-   inferior_exit and executable_changed.  */
-
-static void
-auxv_inferior_data_cleanup (struct inferior *inf, void *arg)
-{
-  struct auxv_info *info;
-
-  info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
-  if (info != NULL)
-    {
-      delete info;
-      set_inferior_data (inf, auxv_inferior_data, NULL);
-    }
-}
+/* Per-inferior data key for auxv.  */
+static const struct inferior_key<auxv_info> auxv_inferior_data;
 
 /* Invalidate INF's auxv cache.  */
 
 static void
 invalidate_auxv_cache_inf (struct inferior *inf)
 {
-  auxv_inferior_data_cleanup (inf, NULL);
+  auxv_inferior_data.clear (inf);
 }
 
 /* Invalidate current inferior's auxv cache.  */
@@ -350,12 +330,11 @@ get_auxv_inferior_data (struct target_ops *ops)
   struct auxv_info *info;
   struct inferior *inf = current_inferior ();
 
-  info = (struct auxv_info *) inferior_data (inf, auxv_inferior_data);
+  info = auxv_inferior_data.get (inf);
   if (info == NULL)
     {
-      info = new auxv_info;
+      info = auxv_inferior_data.emplace (inf);
       info->data = target_read_alloc (ops, TARGET_OBJECT_AUXV, NULL);
-      set_inferior_data (inf, auxv_inferior_data, info);
     }
 
   return info;
@@ -574,10 +553,6 @@ _initialize_auxv (void)
 	    _("Display the inferior's auxiliary vector.\n\
 This is information provided by the operating system at program startup."));
 
-  /* Set an auxv cache per-inferior.  */
-  auxv_inferior_data
-    = register_inferior_data_with_cleanup (NULL, auxv_inferior_data_cleanup);
-
   /* Observers used to invalidate the auxv cache when needed.  */
   gdb::observers::inferior_exit.attach (invalidate_auxv_cache_inf);
   gdb::observers::inferior_appeared.attach (invalidate_auxv_cache_inf);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 09/31] Convert dwarf2_per_objfile to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (20 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 28/31] Convert stabsread.c to type-safe registry API Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 02/31] Convert main_info " Tom Tromey
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes dwarf2_per_objfile to use the type-safe registry API.
This also changes dwarf2_per_objfile not to be allocated on an
obstack.  It seemed clearer to me to simply allocate it on the heap;
and I didn't see a drawback from doing so.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* dwarf2read.h (struct dwarf2_per_objfile): Don't inherit from
	allocate_on_obstack.
	* dwarf2read.c (dwarf2_objfile_data_key): Change type.
	(get_dwarf2_per_objfile): Update.
	(set_dwarf2_per_objfile): Remove.
	(dwarf2_has_info, dwarf2_get_section_info): Update.
	(dwarf2_free_objfile): Remove.
	(_initialize_dwarf2_read): Update.
---
 gdb/ChangeLog    | 11 +++++++++++
 gdb/dwarf2read.c | 43 ++++++-------------------------------------
 gdb/dwarf2read.h |  2 +-
 3 files changed, 18 insertions(+), 38 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b0bdecf96fc..75d940c99a6 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -108,7 +108,7 @@ static int check_physname = 0;
 /* When non-zero, do not reject deprecated .gdb_index sections.  */
 static int use_deprecated_index_sections = 0;
 
-static const struct objfile_data *dwarf2_objfile_data_key;
+static const struct objfile_key<dwarf2_per_objfile> dwarf2_objfile_data_key;
 
 /* The "aclass" indices for various kinds of computed DWARF symbols.  */
 
@@ -281,18 +281,7 @@ struct mapped_debug_names final : public mapped_index_base
 dwarf2_per_objfile *
 get_dwarf2_per_objfile (struct objfile *objfile)
 {
-  return ((struct dwarf2_per_objfile *)
-	  objfile_data (objfile, dwarf2_objfile_data_key));
-}
-
-/* Set the dwarf2_per_objfile associated to OBJFILE.  */
-
-void
-set_dwarf2_per_objfile (struct objfile *objfile,
-			struct dwarf2_per_objfile *dwarf2_per_objfile)
-{
-  gdb_assert (get_dwarf2_per_objfile (objfile) == NULL);
-  set_objfile_data (objfile, dwarf2_objfile_data_key, dwarf2_per_objfile);
+  return dwarf2_objfile_data_key.get (objfile);
 }
 
 /* Default names of the debugging sections.  */
@@ -2251,13 +2240,9 @@ dwarf2_has_info (struct objfile *objfile,
     = get_dwarf2_per_objfile (objfile);
 
   if (dwarf2_per_objfile == NULL)
-    {
-      /* Initialize per-objfile state.  */
-      dwarf2_per_objfile
-	= new (&objfile->objfile_obstack) struct dwarf2_per_objfile (objfile,
-								     names);
-      set_dwarf2_per_objfile (objfile, dwarf2_per_objfile);
-    }
+    dwarf2_per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile,
+							  names);
+
   return (!dwarf2_per_objfile->info.is_virtual
 	  && dwarf2_per_objfile->info.s.section != NULL
 	  && !dwarf2_per_objfile->abbrev.is_virtual
@@ -2589,9 +2574,7 @@ dwarf2_get_section_info (struct objfile *objfile,
                          asection **sectp, const gdb_byte **bufp,
                          bfd_size_type *sizep)
 {
-  struct dwarf2_per_objfile *data
-    = (struct dwarf2_per_objfile *) objfile_data (objfile,
-						  dwarf2_objfile_data_key);
+  struct dwarf2_per_objfile *data = dwarf2_objfile_data_key.get (objfile);
   struct dwarf2_section_info *info;
 
   /* We may see an objfile without any DWARF, in which case we just
@@ -25433,17 +25416,6 @@ free_one_cached_comp_unit (struct dwarf2_per_cu_data *target_per_cu)
     }
 }
 
-/* Cleanup function for the dwarf2_per_objfile data.  */
-
-static void
-dwarf2_free_objfile (struct objfile *objfile, void *datum)
-{
-  struct dwarf2_per_objfile *dwarf2_per_objfile
-    = static_cast<struct dwarf2_per_objfile *> (datum);
-
-  delete dwarf2_per_objfile;
-}
-
 /* A set of CU "per_cu" pointer, DIE offset, and GDB type pointer.
    We store these in a hash table separate from the DIEs, and preserve them
    when the DIEs are flushed out of cache.
@@ -25761,9 +25733,6 @@ show_check_physname (struct ui_file *file, int from_tty,
 void
 _initialize_dwarf2_read (void)
 {
-  dwarf2_objfile_data_key
-    = register_objfile_data_with_cleanup (nullptr, dwarf2_free_objfile);
-
   add_prefix_cmd ("dwarf", class_maintenance, set_dwarf_cmd, _("\
 Set DWARF specific variables.\n\
 Configure DWARF variables such as the cache size"),
diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h
index 34c66167b5b..9a316260be4 100644
--- a/gdb/dwarf2read.h
+++ b/gdb/dwarf2read.h
@@ -102,7 +102,7 @@ typedef struct die_info *die_info_ptr;
 /* Collection of data recorded per objfile.
    This hangs off of dwarf2_objfile_data_key.  */
 
-struct dwarf2_per_objfile : public allocate_on_obstack
+struct dwarf2_per_objfile
 {
   /* Construct a dwarf2_per_objfile for OBJFILE.  NAMES points to the
      dwarf2 section names, or is NULL if the standard ELF names are
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 28/31] Convert stabsread.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (19 preceding siblings ...)
  2019-05-03 23:12 ` [PATCH v2 01/31] Add a type-safe C++ interface to a registry Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 09/31] Convert dwarf2_per_objfile " Tom Tromey
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes stabsread.c to use the type-safe registry API.

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

	* stabsread.c (rs6000_builtin_type_data): Change type.
	(rs6000_builtin_type, _initialize_stabsread): Update.
---
 gdb/ChangeLog   |  5 +++++
 gdb/stabsread.c | 11 +++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 3f340dbf20d..27414a9812a 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2075,13 +2075,14 @@ again:
 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
    Return the proper type node for a given builtin type number.  */
 
-static const struct objfile_data *rs6000_builtin_type_data;
+static const struct objfile_key<struct type *,
+				gdb::noop_deleter<struct type *>>
+  rs6000_builtin_type_data;
 
 static struct type *
 rs6000_builtin_type (int typenum, struct objfile *objfile)
 {
-  struct type **negative_types
-    = (struct type **) objfile_data (objfile, rs6000_builtin_type_data);
+  struct type **negative_types = rs6000_builtin_type_data.get (objfile);
 
   /* We recognize types numbered from -NUMBER_RECOGNIZED to -1.  */
 #define NUMBER_RECOGNIZED 34
@@ -2098,7 +2099,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
       /* This includes an empty slot for type number -0.  */
       negative_types = OBSTACK_CALLOC (&objfile->objfile_obstack,
 				       NUMBER_RECOGNIZED + 1, struct type *);
-      set_objfile_data (objfile, rs6000_builtin_type_data, negative_types);
+      rs6000_builtin_type_data.set (objfile, negative_types);
     }
 
   if (negative_types[-typenum] != NULL)
@@ -4800,8 +4801,6 @@ hashname (const char *name)
 void
 _initialize_stabsread (void)
 {
-  rs6000_builtin_type_data = register_objfile_data ();
-
   undef_types_allocated = 20;
   undef_types_length = 0;
   undef_types = XNEWVEC (struct type *, undef_types_allocated);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 14/31] Convert remote.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (26 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 26/31] Convert hppa-tdep.c to type-safe registry API Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 22/31] Convert nto-tdep.c " Tom Tromey
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes remote.c to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_pspace_data): Change type.
	(remote_pspace_data_cleanup): Remove.
	(get_remote_exec_file, set_pspace_remote_exec_file)
	(_initialize_remote): Update.
---
 gdb/ChangeLog |  7 +++++++
 gdb/remote.c  | 28 ++++++----------------------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 5e5fbbf8c34..dd129b3407a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -969,7 +969,8 @@ public:
 };
 
 /* Per-program-space data key.  */
-static const struct program_space_data *remote_pspace_data;
+static const struct program_space_key<char, gdb::xfree_deleter<char>>
+  remote_pspace_data;
 
 /* The variable registered as the control variable used by the
    remote exec-file commands.  While the remote exec-file setting is
@@ -1229,16 +1230,6 @@ remote_target::get_remote_state ()
   return &m_remote_state;
 }
 
-/* Cleanup routine for the remote module's pspace data.  */
-
-static void
-remote_pspace_data_cleanup (struct program_space *pspace, void *arg)
-{
-  char *remote_exec_file = (char *) arg;
-
-  xfree (remote_exec_file);
-}
-
 /* Fetch the remote exec-file from the current program space.  */
 
 static const char *
@@ -1246,9 +1237,7 @@ get_remote_exec_file (void)
 {
   char *remote_exec_file;
 
-  remote_exec_file
-    = (char *) program_space_data (current_program_space,
-				   remote_pspace_data);
+  remote_exec_file = remote_pspace_data.get (current_program_space);
   if (remote_exec_file == NULL)
     return "";
 
@@ -1259,13 +1248,12 @@ get_remote_exec_file (void)
 
 static void
 set_pspace_remote_exec_file (struct program_space *pspace,
-			char *remote_exec_file)
+			     const char *remote_exec_file)
 {
-  char *old_file = (char *) program_space_data (pspace, remote_pspace_data);
+  char *old_file = remote_pspace_data.get (pspace);
 
   xfree (old_file);
-  set_program_space_data (pspace, remote_pspace_data,
-			  xstrdup (remote_exec_file));
+  remote_pspace_data.set (pspace, xstrdup (remote_exec_file));
 }
 
 /* The "set/show remote exec-file" set command hook.  */
@@ -14263,10 +14251,6 @@ _initialize_remote (void)
   remote_g_packet_data_handle =
     gdbarch_data_register_pre_init (remote_g_packet_data_init);
 
-  remote_pspace_data
-    = register_program_space_data_with_cleanup (NULL,
-						remote_pspace_data_cleanup);
-
   add_target (remote_target_info, remote_target::open);
   add_target (extended_remote_target_info, extended_remote_target::open);
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 27/31] Remove mips_pdr_data
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (24 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 11/31] Convert auxv.c " Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 26/31] Convert hppa-tdep.c to type-safe registry API Tom Tromey
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

mips_pdr_data is unused, so this patch removes it.

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

	* mips-tdep.c (mips_pdr_data): Remove.
	(_initialize_mips_tdep): Update.
---
 gdb/ChangeLog   | 5 +++++
 gdb/mips-tdep.c | 4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f3361388225..3fb53bc76da 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -58,8 +58,6 @@
 #include "target-float.h"
 #include <algorithm>
 
-static const struct objfile_data *mips_pdr_data;
-
 static struct type *mips_register_type (struct gdbarch *gdbarch, int regnum);
 
 static int mips32_instruction_has_delay_slot (struct gdbarch *gdbarch,
@@ -8985,8 +8983,6 @@ _initialize_mips_tdep (void)
 
   gdbarch_register (bfd_arch_mips, mips_gdbarch_init, mips_dump_tdep);
 
-  mips_pdr_data = register_objfile_data ();
-
   /* Create feature sets with the appropriate properties.  The values
      are not important.  */
   mips_tdesc_gp32 = allocate_target_description ();
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 26/31] Convert hppa-tdep.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (25 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 27/31] Remove mips_pdr_data Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 14/31] Convert remote.c " Tom Tromey
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes hppa-tdep.c to use the type-safe registry API.

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

	* hppa-tdep.c (hppa_objfile_priv_data): Change type.
	(hppa_init_objfile_priv_data, read_unwind_info)
	(find_unwind_entry, _initialize_hppa_tdep): Update.
---
 gdb/ChangeLog   |  6 ++++++
 gdb/hppa-tdep.c | 17 +++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index d2b3336cfc7..be30359638c 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -84,7 +84,9 @@ struct hppa_objfile_private
    that separately and make this static. The solib data is probably hpux-
    specific, so we can create a separate extern objfile_data that is registered
    by hppa-hpux-tdep.c and shared with pa64solib.c and somsolib.c.  */
-static const struct objfile_data *hppa_objfile_priv_data = NULL;
+static const struct objfile_key<hppa_objfile_private,
+				gdb::noop_deleter<hppa_objfile_private>>
+  hppa_objfile_priv_data;
 
 /* Get at various relevent fields of an instruction word.  */
 #define MASK_5 0x1f
@@ -208,7 +210,7 @@ hppa_init_objfile_priv_data (struct objfile *objfile)
   hppa_objfile_private *priv
     = OBSTACK_ZALLOC (&objfile->objfile_obstack, hppa_objfile_private);
 
-  set_objfile_data (objfile, hppa_objfile_priv_data, priv);
+  hppa_objfile_priv_data.set (objfile, priv);
 
   return priv;
 }
@@ -466,8 +468,7 @@ read_unwind_info (struct objfile *objfile)
 	 compare_unwind_entries);
 
   /* Keep a pointer to the unwind information.  */
-  obj_private = (struct hppa_objfile_private *) 
-	        objfile_data (objfile, hppa_objfile_priv_data);
+  obj_private = hppa_objfile_priv_data.get (objfile);
   if (obj_private == NULL)
     obj_private = hppa_init_objfile_priv_data (objfile);
 
@@ -501,16 +502,14 @@ find_unwind_entry (CORE_ADDR pc)
     {
       struct hppa_unwind_info *ui;
       ui = NULL;
-      priv = ((struct hppa_objfile_private *)
-	      objfile_data (objfile, hppa_objfile_priv_data));
+      priv = hppa_objfile_priv_data.get (objfile);
       if (priv)
 	ui = ((struct hppa_objfile_private *) priv)->unwind_info;
 
       if (!ui)
 	{
 	  read_unwind_info (objfile);
-	  priv = ((struct hppa_objfile_private *)
-		  objfile_data (objfile, hppa_objfile_priv_data));
+	  priv = hppa_objfile_priv_data.get (objfile);
 	  if (priv == NULL)
 	    error (_("Internal error reading unwind information."));
 	  ui = ((struct hppa_objfile_private *) priv)->unwind_info;
@@ -3174,8 +3173,6 @@ _initialize_hppa_tdep (void)
 {
   gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep);
 
-  hppa_objfile_priv_data = register_objfile_data ();
-
   add_cmd ("unwind", class_maintenance, unwind_command,
 	   _("Print unwind table entry at given address."),
 	   &maintenanceprintlist);
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 02/31] Convert main_info to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (21 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 09/31] Convert dwarf2_per_objfile " Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 29/31] Convert objc-lang.c " Tom Tromey
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes main_info to use the type-safe registry API.

2019-04-22  Tom Tromey  <tom@tromey.com>

	* symtab.c (struct main_info): Add destructor and initializers.
	(main_progspace_key): Move.  Change type.
	(get_main_info): Update.
	(main_info_cleanup): Remove.
	(_initialize_symtab): Update.
---
 gdb/ChangeLog |  8 ++++++++
 gdb/symtab.c  | 44 +++++++++++++++-----------------------------
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 16e641a830b..cf97a1d18e2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -95,23 +95,30 @@ static struct block_symbol
   lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
 			    const char *name, const domain_enum domain);
 
-/* Program space key for finding name and language of "main".  */
-
-static const struct program_space_data *main_progspace_key;
-
 /* Type of the data stored on the program space.  */
 
 struct main_info
 {
+  main_info () = default;
+
+  ~main_info ()
+  {
+    xfree (name_of_main);
+  }
+
   /* Name of "main".  */
 
-  char *name_of_main;
+  char *name_of_main = nullptr;
 
   /* Language of "main".  */
 
-  enum language language_of_main;
+  enum language language_of_main = language_unknown;
 };
 
+/* Program space key for finding name and language of "main".  */
+
+static const program_space_key<main_info> main_progspace_key;
+
 /* Program space key for finding its symbol cache.  */
 
 static const struct program_space_data *symbol_cache_key;
@@ -5665,9 +5672,7 @@ make_source_files_completion_list (const char *text, const char *word)
 static struct main_info *
 get_main_info (void)
 {
-  struct main_info *info
-    = (struct main_info *) program_space_data (current_program_space,
-					       main_progspace_key);
+  struct main_info *info = main_progspace_key.get (current_program_space);
 
   if (info == NULL)
     {
@@ -5677,28 +5682,12 @@ get_main_info (void)
 	 gdb returned "main" as the name even if no function named
 	 "main" was defined the program; and this approach lets us
 	 keep compatibility.  */
-      info = XCNEW (struct main_info);
-      info->language_of_main = language_unknown;
-      set_program_space_data (current_program_space, main_progspace_key,
-			      info);
+      info = main_progspace_key.emplace (current_program_space);
     }
 
   return info;
 }
 
-/* A cleanup to destroy a struct main_info when a progspace is
-   destroyed.  */
-
-static void
-main_info_cleanup (struct program_space *pspace, void *data)
-{
-  struct main_info *info = (struct main_info *) data;
-
-  if (info != NULL)
-    xfree (info->name_of_main);
-  xfree (info);
-}
-
 static void
 set_main_name (const char *name, enum language lang)
 {
@@ -6048,9 +6037,6 @@ _initialize_symtab (void)
 {
   initialize_ordinary_address_classes ();
 
-  main_progspace_key
-    = register_program_space_data_with_cleanup (NULL, main_info_cleanup);
-
   symbol_cache_key
     = register_program_space_data_with_cleanup (NULL, symbol_cache_cleanup);
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 29/31] Convert objc-lang.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (22 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 02/31] Convert main_info " Tom Tromey
@ 2019-05-03 23:13 ` Tom Tromey
  2019-05-03 23:13 ` [PATCH v2 11/31] Convert auxv.c " Tom Tromey
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes objc-lang.c to use the type-safe registry API.

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

	* objc-lang.c (objc_objfile_data): Change type.
	(find_methods): Update.
	(_initialize_objc_lang): Remove.
---
 gdb/ChangeLog   |  6 ++++++
 gdb/objc-lang.c | 16 +++-------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index b25a98106c1..ab40e54a169 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -75,7 +75,7 @@ struct objc_method {
   CORE_ADDR imp;
 };
 
-static const struct objfile_data *objc_objfile_data;
+static const struct objfile_key<unsigned int> objc_objfile_data;
 
 /* Lookup a structure type named "struct NAME", visible in lexical
    block BLOCK.  If NOERR is nonzero, return zero if NAME is not
@@ -1004,7 +1004,7 @@ find_methods (char type, const char *theclass, const char *category,
 
       unsigned int objfile_csym = 0;
 
-      objc_csym = (unsigned int *) objfile_data (objfile, objc_objfile_data);
+      objc_csym = objc_objfile_data.get (objfile);
       if (objc_csym != NULL && *objc_csym == 0)
 	/* There are no ObjC symbols in this objfile.  Skip it entirely.  */
 	continue;
@@ -1056,11 +1056,7 @@ find_methods (char type, const char *theclass, const char *category,
 	}
 
       if (objc_csym == NULL)
-	{
-	  objc_csym = XOBNEW (&objfile->objfile_obstack, unsigned int);
-	  *objc_csym = objfile_csym;
-	  set_objfile_data (objfile, objc_objfile_data, objc_csym);
-	}
+	objc_csym = objc_objfile_data.emplace (objfile, objfile_csym);
       else
 	/* Count of ObjC methods in this objfile should be constant.  */
 	gdb_assert (*objc_csym == objfile_csym);
@@ -1576,9 +1572,3 @@ resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
     return 1;
   return 0;
 }
-
-void
-_initialize_objc_lang (void)
-{
-  objc_objfile_data = register_objfile_data ();
-}
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 31/31] Convert gdbtypes.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (29 preceding siblings ...)
  2019-05-03 23:31 ` [PATCH v2 30/31] Convert dwarf2-frame.c " Tom Tromey
@ 2019-05-03 23:31 ` Tom Tromey
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes gdbtypes.c to use the type-safe registry API.

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

	* gdbtypes.c (objfile_type_data): Change type.
	(objfile_type, _initialize_gdbtypes): Update.
---
 gdb/ChangeLog  |  5 +++++
 gdb/gdbtypes.c | 10 +++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b3424d81be4..59456f9f3a4 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5458,14 +5458,15 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
 /* This set of objfile-based types is intended to be used by symbol
    readers as basic types.  */
 
-static const struct objfile_data *objfile_type_data;
+static const struct objfile_key<struct objfile_type,
+				gdb::noop_deleter<struct objfile_type>>
+  objfile_type_data;
 
 const struct objfile_type *
 objfile_type (struct objfile *objfile)
 {
   struct gdbarch *gdbarch;
-  struct objfile_type *objfile_type
-    = (struct objfile_type *) objfile_data (objfile, objfile_type_data);
+  struct objfile_type *objfile_type = objfile_type_data.get (objfile);
 
   if (objfile_type)
     return objfile_type;
@@ -5570,7 +5571,7 @@ objfile_type (struct objfile *objfile)
     = init_integer_type (objfile, gdbarch_addr_bit (gdbarch), 1,
 			 "__CORE_ADDR");
 
-  set_objfile_data (objfile, objfile_type_data, objfile_type);
+  objfile_type_data.set (objfile, objfile_type);
   return objfile_type;
 }
 
@@ -5578,7 +5579,6 @@ void
 _initialize_gdbtypes (void)
 {
   gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
-  objfile_type_data = register_objfile_data ();
 
   add_setshow_zuinteger_cmd ("overload", no_class, &overload_debug,
 			     _("Set debugging of C++ overloading."),
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2 30/31] Convert dwarf2-frame.c to type-safe registry API
  2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
                   ` (28 preceding siblings ...)
  2019-05-03 23:13 ` [PATCH v2 22/31] Convert nto-tdep.c " Tom Tromey
@ 2019-05-03 23:31 ` Tom Tromey
  2019-05-03 23:31 ` [PATCH v2 31/31] Convert gdbtypes.c " Tom Tromey
  30 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-03 23:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes dwarf2-frame.c to use the type-safe registry API.

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

	* dwarf2-frame.c (dwarf2_frame_objfile_data): Change type.
	(dwarf2_frame_find_fde, dwarf2_build_frame_info)
	(_initialize_dwarf2_frame): Update.
---
 gdb/ChangeLog      |  6 ++++++
 gdb/dwarf2-frame.c | 13 ++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index b697afa5a13..0f2502b4c68 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1463,7 +1463,9 @@ dwarf2_frame_cfa (struct frame_info *this_frame)
   return get_frame_base (this_frame);
 }
 \f
-const struct objfile_data *dwarf2_frame_objfile_data;
+const struct objfile_key<dwarf2_fde_table,
+			 gdb::noop_deleter<dwarf2_fde_table>>
+  dwarf2_frame_objfile_data;
 
 static unsigned int
 read_1_byte (bfd *abfd, const gdb_byte *buf)
@@ -1708,13 +1710,11 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
       CORE_ADDR offset;
       CORE_ADDR seek_pc;
 
-      fde_table = ((struct dwarf2_fde_table *)
-		   objfile_data (objfile, dwarf2_frame_objfile_data));
+      fde_table = dwarf2_frame_objfile_data.get (objfile);
       if (fde_table == NULL)
 	{
 	  dwarf2_build_frame_info (objfile);
-	  fde_table = ((struct dwarf2_fde_table *)
-		       objfile_data (objfile, dwarf2_frame_objfile_data));
+	  fde_table = dwarf2_frame_objfile_data.get (objfile);
 	}
       gdb_assert (fde_table != NULL);
 
@@ -2397,7 +2397,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
       xfree (fde_table.entries);
     }
 
-  set_objfile_data (objfile, dwarf2_frame_objfile_data, fde_table2);
+  dwarf2_frame_objfile_data.set (objfile, fde_table2);
 }
 
 /* Handle 'maintenance show dwarf unwinders'.  */
@@ -2416,7 +2416,6 @@ void
 _initialize_dwarf2_frame (void)
 {
   dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
-  dwarf2_frame_objfile_data = register_objfile_data ();
 
   add_setshow_boolean_cmd ("unwinders", class_obscure,
 			   &dwarf2_frame_unwinders_enabled_p , _("\
-- 
2.17.2

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v2 19/31] Convert fbsd-tdep.c to type-safe registry API
  2019-05-03 23:12 ` [PATCH v2 19/31] Convert fbsd-tdep.c " Tom Tromey
@ 2019-05-06 20:56   ` John Baldwin
  2019-05-08 17:58     ` Tom Tromey
  0 siblings, 1 reply; 35+ messages in thread
From: John Baldwin @ 2019-05-06 20:56 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 5/3/19 4:12 PM, Tom Tromey wrote:
> This changes fbsd-tdep.c to use the type-safe registry API.
> 
> 2019-05-01  Tom Tromey  <tom@tromey.com>
> 
> 	* fbsd-tdep.c (struct fbsd_pspace_data): Add initializers.
> 	(fbsd_pspace_data_handle): Move lower.  Change type.
> 	(get_fbsd_pspace_data): Update.
> 	(fbsd_pspace_data_cleanup): Remove.
> 	(_initialize_fbsd_tdep): Update.

Thanks, this file looks good to me at least.  I'm also still in
favor of the general idea.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v2 19/31] Convert fbsd-tdep.c to type-safe registry API
  2019-05-06 20:56   ` John Baldwin
@ 2019-05-08 17:58     ` Tom Tromey
  2019-05-08 22:06       ` Tom Tromey
  0 siblings, 1 reply; 35+ messages in thread
From: Tom Tromey @ 2019-05-08 17:58 UTC (permalink / raw)
  To: John Baldwin; +Cc: Tom Tromey, gdb-patches

>>>>> "John" == John Baldwin <jhb@FreeBSD.org> writes:

John> On 5/3/19 4:12 PM, Tom Tromey wrote:
>> This changes fbsd-tdep.c to use the type-safe registry API.
>> 
>> 2019-05-01  Tom Tromey  <tom@tromey.com>
>> 
>> * fbsd-tdep.c (struct fbsd_pspace_data): Add initializers.
>> (fbsd_pspace_data_handle): Move lower.  Change type.
>> (get_fbsd_pspace_data): Update.
>> (fbsd_pspace_data_cleanup): Remove.
>> (_initialize_fbsd_tdep): Update.

John> Thanks, this file looks good to me at least.  I'm also still in
John> favor of the general idea.

Thanks.  I'll check these in pretty soon, maybe this evening.

Tom

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v2 19/31] Convert fbsd-tdep.c to type-safe registry API
  2019-05-08 17:58     ` Tom Tromey
@ 2019-05-08 22:06       ` Tom Tromey
  0 siblings, 0 replies; 35+ messages in thread
From: Tom Tromey @ 2019-05-08 22:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: John Baldwin, gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

John> Thanks, this file looks good to me at least.  I'm also still in
John> favor of the general idea.

Tom> Thanks.  I'll check these in pretty soon, maybe this evening.

I'm doing this now.
I may convert some of the remaining ones to the type-safe API.  I'd like
to get rid of it entirely but there are a few required changes I
wouldn't be able to test :-(

Tom

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2019-05-08 22:06 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 23:12 [PATCH v2 00/31] Add a type-safe API to registries Tom Tromey
2019-05-03 23:12 ` [PATCH v2 16/31] Convert xcoffread.c to type-safe registry API Tom Tromey
2019-05-03 23:12 ` [PATCH v2 04/31] Convert target dcache " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 05/31] Convert inflow " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 07/31] Convert objfiles.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 24/31] Convert mdebugread.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 21/31] Convert ada-lang.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 13/31] Convert breakpoint.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 15/31] Convert solib-svr4.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 19/31] Convert fbsd-tdep.c " Tom Tromey
2019-05-06 20:56   ` John Baldwin
2019-05-08 17:58     ` Tom Tromey
2019-05-08 22:06       ` Tom Tromey
2019-05-03 23:12 ` [PATCH v2 06/31] Convert break-catch-syscall.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 03/31] Convert symbol_cache " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 17/31] Convert probes " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 12/31] Convert linux-tdep.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 08/31] Convert auto-load.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 10/31] Convert symfile-debug.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 20/31] Convert coffread.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 25/31] Convert elfread.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 18/31] Convert ada-tasks.c " Tom Tromey
2019-05-03 23:12 ` [PATCH v2 23/31] Add a noop deleter Tom Tromey
2019-05-03 23:12 ` [PATCH v2 01/31] Add a type-safe C++ interface to a registry Tom Tromey
2019-05-03 23:13 ` [PATCH v2 28/31] Convert stabsread.c to type-safe registry API Tom Tromey
2019-05-03 23:13 ` [PATCH v2 09/31] Convert dwarf2_per_objfile " Tom Tromey
2019-05-03 23:13 ` [PATCH v2 02/31] Convert main_info " Tom Tromey
2019-05-03 23:13 ` [PATCH v2 29/31] Convert objc-lang.c " Tom Tromey
2019-05-03 23:13 ` [PATCH v2 11/31] Convert auxv.c " Tom Tromey
2019-05-03 23:13 ` [PATCH v2 27/31] Remove mips_pdr_data Tom Tromey
2019-05-03 23:13 ` [PATCH v2 26/31] Convert hppa-tdep.c to type-safe registry API Tom Tromey
2019-05-03 23:13 ` [PATCH v2 14/31] Convert remote.c " Tom Tromey
2019-05-03 23:13 ` [PATCH v2 22/31] Convert nto-tdep.c " Tom Tromey
2019-05-03 23:31 ` [PATCH v2 30/31] Convert dwarf2-frame.c " Tom Tromey
2019-05-03 23:31 ` [PATCH v2 31/31] Convert gdbtypes.c " Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).