public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Convert fbsd-tdep.c to type-safe registry API
@ 2019-05-08 22:09 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-05-08 22:09 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4e05d2fea956e65618fc12c57fb81e8788ef07d
commit d4e05d2fea956e65618fc12c57fb81e8788ef07d
Author: Tom Tromey <tom@tromey.com>
Date: Wed May 1 15:05:58 2019 -0600
Convert fbsd-tdep.c to type-safe registry API
This changes fbsd-tdep.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 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.
Diff:
---
gdb/ChangeLog | 8 ++++++++
gdb/fbsd-tdep.c | 31 +++++++++----------------------
2 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f19cb88..9bc8f99 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2019-05-08 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.
+
+2019-05-08 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.
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 4efa0f7..cc7c2b7 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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-08 22:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-08 22:09 [binutils-gdb] Convert fbsd-tdep.c to type-safe registry API 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).