From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/3] Pass inferior to terminal_inferior
Date: Tue, 16 Oct 2018 03:38:00 -0000 [thread overview]
Message-ID: <20181016033835.17594-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20181016033835.17594-1-simon.marchi@polymtl.ca>
Same as the previous patch, but for the terminal_inferior method.
gdb/ChangeLog:
* target.h (struct target_ops) <terminal_inferior>: Add inferior
pointer parameter.
* target.c (target_terminal::inferior): Pass inferior to
terminal_inferior.
* target-delegates.c: Re-generate.
* inf-child.h (inf_child_target) <terminal_inferior>: Add
inferior pointer parameter.
* inf-child.c (inf_child_target::terminal_inferior): Likewise.
* inferior.h (child_terminal_inferior): Likewise.
* inflow.c (child_terminal_inferior): Likewise.
* remote.c (struct remote_target) <terminal_inferior>: Likewise.
(remote_target::terminal_inferior): Likewise.
---
gdb/inf-child.c | 4 ++--
gdb/inf-child.h | 2 +-
gdb/inferior.h | 2 +-
gdb/inflow.c | 3 +--
gdb/remote.c | 4 ++--
gdb/target-delegates.c | 15 ++++++++-------
gdb/target.c | 5 ++---
gdb/target.h | 9 ++++++++-
8 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 94f42ec2adc0..f02720028211 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -108,9 +108,9 @@ inf_child_target::terminal_init ()
}
void
-inf_child_target::terminal_inferior ()
+inf_child_target::terminal_inferior (inferior *inf)
{
- child_terminal_inferior (this);
+ child_terminal_inferior (this, inf);
}
void
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index b0625391ebb2..c544ceaf520e 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -45,7 +45,7 @@ public:
bool supports_terminal_ours () override;
void terminal_init () override;
- void terminal_inferior () override;
+ void terminal_inferior (inferior *inf) override;
void terminal_save_inferior (inferior *inf) override;
void terminal_ours_for_output () override;
void terminal_ours () override;
diff --git a/gdb/inferior.h b/gdb/inferior.h
index d09263e34bef..badd82e17c35 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -152,7 +152,7 @@ extern void child_terminal_ours (struct target_ops *self);
extern void child_terminal_ours_for_output (struct target_ops *self);
-extern void child_terminal_inferior (struct target_ops *self);
+extern void child_terminal_inferior (struct target_ops *self, inferior *inf);
extern void child_terminal_save_inferior (struct target_ops *self,
inferior *inf);
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 372ef7844f01..e355f4aa9fc5 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -342,7 +342,7 @@ sharing_input_terminal (inferior *inf)
preparation for starting or resuming the inferior. */
void
-child_terminal_inferior (struct target_ops *self)
+child_terminal_inferior (struct target_ops *self, inferior *inf)
{
/* If we resume more than one inferior in the foreground on GDB's
terminal, then the first inferior's terminal settings "win".
@@ -353,7 +353,6 @@ child_terminal_inferior (struct target_ops *self)
if (gdb_tty_state == target_terminal_state::is_inferior)
return;
- inferior *inf = current_inferior ();
terminal_info *tinfo = get_inflow_inferior_data (inf);
if (gdb_has_a_terminal ()
diff --git a/gdb/remote.c b/gdb/remote.c
index c53553af5bda..268cce84afa8 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -557,7 +557,7 @@ public:
int can_do_single_step () override;
- void terminal_inferior () override;
+ void terminal_inferior (inferior *inf) override;
void terminal_ours () override;
@@ -6812,7 +6812,7 @@ remote_target::interrupt_query ()
is required. */
void
-remote_target::terminal_inferior ()
+remote_target::terminal_inferior (inferior *inf)
{
/* NOTE: At this point we could also register our selves as the
recipient of all input. Any characters typed could then be
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index f2b352c44888..1d1bd0ae4234 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -44,7 +44,7 @@ struct dummy_target : public target_ops
int can_do_single_step () override;
bool supports_terminal_ours () override;
void terminal_init () override;
- void terminal_inferior () override;
+ void terminal_inferior (inferior *arg0) override;
void terminal_save_inferior (inferior *arg0) override;
void terminal_ours_for_output () override;
void terminal_ours () override;
@@ -211,7 +211,7 @@ struct debug_target : public target_ops
int can_do_single_step () override;
bool supports_terminal_ours () override;
void terminal_init () override;
- void terminal_inferior () override;
+ void terminal_inferior (inferior *arg0) override;
void terminal_save_inferior (inferior *arg0) override;
void terminal_ours_for_output () override;
void terminal_ours () override;
@@ -1229,22 +1229,23 @@ debug_target::terminal_init ()
}
void
-target_ops::terminal_inferior ()
+target_ops::terminal_inferior (inferior *arg0)
{
- this->beneath ()->terminal_inferior ();
+ this->beneath ()->terminal_inferior (arg0);
}
void
-dummy_target::terminal_inferior ()
+dummy_target::terminal_inferior (inferior *arg0)
{
}
void
-debug_target::terminal_inferior ()
+debug_target::terminal_inferior (inferior *arg0)
{
fprintf_unfiltered (gdb_stdlog, "-> %s->terminal_inferior (...)\n", this->beneath ()->shortname ());
- this->beneath ()->terminal_inferior ();
+ this->beneath ()->terminal_inferior (arg0);
fprintf_unfiltered (gdb_stdlog, "<- %s->terminal_inferior (", this->beneath ()->shortname ());
+ target_debug_print_inferior_p (arg0);
fputs_unfiltered (")\n", gdb_stdlog);
}
diff --git a/gdb/target.c b/gdb/target.c
index 93d16b90f179..631b2c3b0f12 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -444,7 +444,7 @@ target_terminal::inferior (void)
if (inf->terminal_state != target_terminal_state::is_inferior)
{
- current_top_target ()->terminal_inferior ();
+ current_top_target ()->terminal_inferior (inf);
inf->terminal_state = target_terminal_state::is_inferior;
}
@@ -479,8 +479,7 @@ target_terminal::restore_inferior (void)
{
if (inf->terminal_state == target_terminal_state::is_ours_for_output)
{
- set_current_inferior (inf);
- current_top_target ()->terminal_inferior ();
+ current_top_target ()->terminal_inferior (inf);
inf->terminal_state = target_terminal_state::is_inferior;
}
}
diff --git a/gdb/target.h b/gdb/target.h
index c37405205a0a..310c942bbe5b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -581,7 +581,14 @@ struct target_ops
TARGET_DEFAULT_RETURN (false);
virtual void terminal_init ()
TARGET_DEFAULT_IGNORE ();
- virtual void terminal_inferior ()
+
+ /* If INF shares a terminal with GDB, restore the saved terminal settings
+ associated to INF (see terminal_save_inferior) to the current
+ terminal. In a scenario where multiple inferiors share GDB's terminal,
+ don't apply the settings of another inferior's settings are currently
+ applied (in other words, the first inferior's settings win and should not
+ be overwritten). */
+ virtual void terminal_inferior (inferior *inf)
TARGET_DEFAULT_IGNORE ();
/* If INF shares a terminal with GDB, save the current terminal settings
--
2.19.1
next prev parent reply other threads:[~2018-10-16 3:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-16 3:38 [PATCH 1/3] Pass inferior to terminal_save_inferior Simon Marchi
2018-10-16 3:38 ` Simon Marchi [this message]
2018-10-22 20:54 ` [PATCH 2/3] Pass inferior to terminal_inferior Pedro Alves
2018-10-23 9:14 ` Simon Marchi
2018-10-16 3:38 ` [PATCH 3/3] Avoid GDB SIGTTOU on catch exec + set follow-exec-mode new (PR 23368) Simon Marchi
[not found] ` <37bde004-853a-3ccc-3777-03cc43b36147@redhat.com>
2018-10-20 15:14 ` Simon Marchi
2018-10-20 15:38 ` Simon Marchi
2018-10-22 20:56 ` Pedro Alves
2018-10-23 9:49 ` Simon Marchi
2018-10-23 10:55 ` Pedro Alves
[not found] ` <mvmftwvr8ao.fsf@suse.de>
2018-10-24 14:08 ` Simon Marchi
2018-10-22 20:54 ` [PATCH 1/3] Pass inferior to terminal_save_inferior Pedro Alves
2018-10-23 9:01 ` Simon Marchi
2018-10-23 11:11 ` Pedro Alves
2018-10-23 20:56 ` Simon Marchi
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=20181016033835.17594-2-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--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