From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/6] Store remote fileio state in remote_state
Date: Sun, 31 Dec 2023 13:25:43 -0700 [thread overview]
Message-ID: <20231231-remote-fileio-v1-6-249cc6c440d9@tromey.com> (raw)
In-Reply-To: <20231231-remote-fileio-v1-0-249cc6c440d9@tromey.com>
This removes the global 'remote_fio_data', moving it to remote_state.
This in turn lets each remote target manage its own file descriptors.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31189
---
gdb/remote-fileio.c | 16 ----------------
gdb/remote-fileio.h | 8 --------
gdb/remote.c | 8 +++++---
3 files changed, 5 insertions(+), 27 deletions(-)
diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
index a954ab1bb55..14ca2ecca44 100644
--- a/gdb/remote-fileio.c
+++ b/gdb/remote-fileio.c
@@ -37,8 +37,6 @@
#endif
#include <signal.h>
-static remote_fileio_data remote_fio_data;
-
#define FIO_FD_INVALID -1
#define FIO_FD_CONSOLE_IN -2
#define FIO_FD_CONSOLE_OUT -3
@@ -1141,14 +1139,6 @@ remote_fileio_data::do_request (remote_target *remote, char *buf)
remote_fileio_reply (remote, -1, FILEIO_ENOSYS);
}
-/* Close any open descriptors, and reinitialize the file mapping. */
-
-void
-remote_fileio_reset ()
-{
- remote_fio_data.reset ();
-}
-
/* Handle a file I/O request. BUF points to the packet containing the
request. CTRLC_PENDING_P should be nonzero if the target has not
acknowledged the Ctrl-C sent asynchronously earlier. */
@@ -1193,12 +1183,6 @@ remote_fileio_data::request (remote_target *remote,
quit_handler = remote_fileio_o_quit_handler;
}
-
-void
-remote_fileio_request (remote_target *remote, char *buf, int ctrlc_pending_p)
-{
- remote_fio_data.request (remote, buf, ctrlc_pending_p);
-}
\f
/* Unpack an fio_uint_t. */
diff --git a/gdb/remote-fileio.h b/gdb/remote-fileio.h
index c632c9e40f8..295a4719436 100644
--- a/gdb/remote-fileio.h
+++ b/gdb/remote-fileio.h
@@ -65,14 +65,6 @@ struct remote_fileio_data
std::vector<int> m_fd_map;
};
-/* Unified interface to remote fileio, called in remote.c from
- remote_wait () and remote_async_wait (). */
-extern void remote_fileio_request (remote_target *remote,
- char *buf, int ctrlc_pending_p);
-
-/* Cleanup any remote fileio state. */
-extern void remote_fileio_reset (void);
-
/* Called from _initialize_remote (). */
extern void initialize_remote_fileio (
struct cmd_list_element **remote_set_cmdlist,
diff --git a/gdb/remote.c b/gdb/remote.c
index dcc1a0d0639..7409b014ea4 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -603,6 +603,9 @@ class remote_state
qSupported. */
gdb_thread_options supported_thread_options = 0;
+ /* Data needed for remote fileio. */
+ remote_fileio_data remote_fio;
+
private:
/* Asynchronous signal handle registered as event loop source for
when we have pending events ready to be passed to the core. */
@@ -4428,7 +4431,7 @@ remote_target::extended_remote_restart ()
xsnprintf (rs->buf.data (), get_remote_packet_size (), "R%x", 0);
putpkt (rs->buf);
- remote_fileio_reset ();
+ rs->remote_fio.reset ();
}
\f
/* Clean up connection to a remote debugger. */
@@ -6068,7 +6071,6 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
/* Here the possibly existing remote target gets unpushed. */
target_preopen (from_tty);
- remote_fileio_reset ();
reopen_exec_file ();
reread_symbols (from_tty);
@@ -8602,7 +8604,7 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status,
for a stop reply. See the comments in putpkt_binary. Set
waiting_for_stop_reply to 0 temporarily. */
rs->waiting_for_stop_reply = 0;
- remote_fileio_request (this, buf, rs->ctrlc_pending_p);
+ rs->remote_fio.request (this, buf, rs->ctrlc_pending_p);
rs->ctrlc_pending_p = 0;
/* GDB handled the File-I/O request, and the target is running
again. Keep waiting for events. */
--
2.43.0
next prev parent reply other threads:[~2023-12-31 20:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 20:25 [PATCH 0/6] Make remote-fileio per-target Tom Tromey
2023-12-31 20:25 ` [PATCH 1/6] Make remote_fio_func_map 'const' Tom Tromey
2023-12-31 20:25 ` [PATCH 2/6] Use vector in remote-fileio.c Tom Tromey
2024-01-01 14:20 ` Lancelot SIX
2024-01-01 18:39 ` Simon Marchi
2023-12-31 20:25 ` [PATCH 3/6] Use methods for remote fileio Tom Tromey
2023-12-31 20:25 ` [PATCH 4/6] Remove sentinel from remote_fio_func_map Tom Tromey
2023-12-31 20:25 ` [PATCH 5/6] Move remote_fileio_data to header file Tom Tromey
2023-12-31 20:25 ` Tom Tromey [this message]
2024-01-01 14:28 ` [PATCH 0/6] Make remote-fileio per-target Lancelot SIX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231231-remote-fileio-v1-6-249cc6c440d9@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox