aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-04-21 12:48:39 -0600
committerTom Tromey <tom@tromey.com>2019-05-08 16:01:50 -0600
commit7b4a314f8b9b50c2289ca6b5d21513052c48730b (patch)
tree0b0e8a2545f794b23daf2844a090d6b5fd8694b7
parent51d3063a35fad1fa0cd53c167bb5a4325afeea16 (diff)
downloadfsf-binutils-gdb-7b4a314f8b9b50c2289ca6b5d21513052c48730b.zip
fsf-binutils-gdb-7b4a314f8b9b50c2289ca6b5d21513052c48730b.tar.gz
fsf-binutils-gdb-7b4a314f8b9b50c2289ca6b5d21513052c48730b.tar.bz2
Convert remote.c to type-safe registry API
This changes remote.c to use the type-safe registry API. gdb/ChangeLog 2019-05-08 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.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/remote.c28
2 files changed, 13 insertions, 22 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 05a06ec..f93c27c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2019-05-08 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.
+
+2019-05-08 Tom Tromey <tom@tromey.com>
+
* breakpoint.c (breakpoint_objfile_key): Change type.
(get_breakpoint_objfile_data): Update.
(free_breakpoint_objfile_data): Remove.
diff --git a/gdb/remote.c b/gdb/remote.c
index 81e6427..dc73472 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. */
@@ -14277,10 +14265,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);