From: "Alexandra Hájková" <ahajkova@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 5/6] remote.c: Add terminal handling functions
Date: Fri, 19 Jan 2024 12:56:29 +0100 [thread overview]
Message-ID: <20240119115659.491195-7-ahajkova@redhat.com> (raw)
In-Reply-To: <20240119115659.491195-1-ahajkova@redhat.com>
Re-use terminal handling functions from inf-child.c so GDBserver can
call them. This helps local remote target to behave more like native
target.
---
gdb/remote.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/gdb/remote.c b/gdb/remote.c
index d90e071f4fb..3406eaf43e7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -607,6 +607,10 @@ class remote_state
qSupported. */
gdb_thread_options supported_thread_options = 0;
+ /* gdbserver accepted the file descriptor numbers of the terminal
+ GDB is connected to. */
+ bool fds_accepted = false;
+
private:
/* Asynchronous signal handle registered as event loop source for
when we have pending events ready to be passed to the core. */
@@ -908,10 +912,18 @@ class remote_target : public process_stratum_target
int can_do_single_step () override;
+ bool supports_terminal_ours () override;
+
+ void terminal_init () override;
+
void terminal_inferior () override;
+ void terminal_save_inferior() override;
+
void terminal_ours () override;
+ void terminal_ours_for_output() override;
+
bool supports_non_stop () override;
bool supports_multi_process () override;
@@ -1731,6 +1743,36 @@ remote_target::get_remote_state ()
return &m_remote_state;
}
+bool
+remote_target::supports_terminal_ours ()
+{
+ return true;
+}
+
+void
+remote_target::terminal_init ()
+{
+ struct remote_state *rs = get_remote_state ();
+ if (rs->fds_accepted)
+ child_terminal_init (this);
+}
+
+void
+remote_target::terminal_save_inferior ()
+{
+ struct remote_state *rs = get_remote_state ();
+ if (rs->fds_accepted)
+ child_terminal_save_inferior (this);
+}
+
+void
+remote_target::terminal_ours_for_output ()
+{
+ struct remote_state *rs = get_remote_state ();
+ if (rs->fds_accepted)
+ child_terminal_ours_for_output (this);
+}
+
/* Fetch the remote exec-file from the current program space. */
static const char *
@@ -5035,6 +5077,12 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
putpkt (rs->buf);
getpkt (&rs->buf, 0);
+
+ if (m_features.packet_ok (rs->buf, PACKET_vDefaultInferiorFd) == PACKET_OK)
+ rs->fds_accepted = true;
+ else
+ error (_("Remote replied unexpectedly to 'vDefaultInferiorFd': %s"),
+ rs->buf.data ());
}
/* Check vCont support and set the remote state's vCont_action_support
@@ -7565,11 +7613,18 @@ remote_target::terminal_inferior ()
/* NOTE: At this point we could also register our selves as the
recipient of all input. Any characters typed could then be
passed on down to the target. */
+
+ struct remote_state *rs = get_remote_state ();
+ if (rs->fds_accepted)
+ child_terminal_inferior (this);
}
void
remote_target::terminal_ours ()
{
+ struct remote_state *rs = get_remote_state ();
+ if (rs->fds_accepted)
+ child_terminal_ours (this);
}
static void
--
2.43.0
next prev parent reply other threads:[~2024-01-19 11:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 11:56 [PATCH v2 0/6] Add vDefaultInferiorFd feature Alexandra Hájková
2024-01-19 11:56 ` [PATCH v2 1/6] gdb.server/non-existing-program.exp: Use gdbserver_start Alexandra Hájková
2024-01-19 11:56 ` [PATCH v2] remote.c: Make packet_check_result return a structure Alexandra Hájková
2024-02-22 14:37 ` Alexandra Petlanova Hajkova
2024-02-23 16:19 ` Tom Tromey
2024-01-19 11:56 ` [PATCH v2 2/6] gdb/ser-pipe.c: Duplicate the file descriptors Alexandra Hájková
2024-01-19 11:56 ` [PATCH v2 3/6] Add new vDefaultInferiorFd packet Alexandra Hájková
2024-01-19 12:04 ` Eli Zaretskii
2024-01-19 11:56 ` [PATCH v2 4/6] gdbserver/linux-low.cc: Connect the inferior to the terminal Alexandra Hájková
2024-01-19 11:56 ` Alexandra Hájková [this message]
2024-01-19 11:56 ` [PATCH v2 6/6] Add defaultinf.exp test to the testsuite Alexandra Hájková
2024-02-22 14:38 ` [PATCH v2 0/6] Add vDefaultInferiorFd feature Alexandra Petlanova Hajkova
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=20240119115659.491195-7-ahajkova@redhat.com \
--to=ahajkova@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).