aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/target.c56
-rw-r--r--gdb/target.h20
-rw-r--r--gdb/windows-nat.c2
4 files changed, 81 insertions, 14 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c60c7a..ae4fef6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
2014-10-17 Pedro Alves <palves@redhat.com>
+ * target.c (enum terminal_state): New enum.
+ (terminal_state): New global.
+ (target_terminal_init): New function.
+ (target_terminal_inferior): Skip if inferior already owns the
+ terminal.
+ (target_terminal_ours, target_terminal_ours_for_output): New
+ functions.
+ * target.h (target_terminal_init): Convert to function prototype.
+ (target_terminal_ours_for_output): Convert to function prototype
+ and tweak comment.
+ (target_terminal_ours): Convert to function prototype and tweak
+ comment.
+ * windows-nat.c (do_initial_windows_stuff): Call
+ target_terminal_init instead of child_terminal_init_with_pgrp.
+
+2014-10-17 Pedro Alves <palves@redhat.com>
+
* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
diff --git a/gdb/target.c b/gdb/target.c
index fcd877c..7feaa35 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -432,6 +432,35 @@ target_load (const char *arg, int from_tty)
(*current_target.to_load) (&current_target, arg, from_tty);
}
+/* Possible terminal states. */
+
+enum terminal_state
+ {
+ /* The inferior's terminal settings are in effect. */
+ terminal_is_inferior = 0,
+
+ /* Some of our terminal settings are in effect, enough to get
+ proper output. */
+ terminal_is_ours_for_output = 1,
+
+ /* Our terminal settings are in effect, for output and input. */
+ terminal_is_ours = 2
+ };
+
+static enum terminal_state terminal_state;
+
+/* See target.h. */
+
+void
+target_terminal_init (void)
+{
+ (*current_target.to_terminal_init) (&current_target);
+
+ terminal_state = terminal_is_ours;
+}
+
+/* See target.h. */
+
void
target_terminal_inferior (void)
{
@@ -442,9 +471,36 @@ target_terminal_inferior (void)
if (target_can_async_p () && !sync_execution)
return;
+ if (terminal_state == terminal_is_inferior)
+ return;
+
/* If GDB is resuming the inferior in the foreground, install
inferior's terminal modes. */
(*current_target.to_terminal_inferior) (&current_target);
+ terminal_state = terminal_is_inferior;
+}
+
+/* See target.h. */
+
+void
+target_terminal_ours (void)
+{
+ if (terminal_state == terminal_is_ours)
+ return;
+
+ (*current_target.to_terminal_ours) (&current_target);
+ terminal_state = terminal_is_ours;
+}
+
+/* See target.h. */
+
+void
+target_terminal_ours_for_output (void)
+{
+ if (terminal_state != terminal_is_inferior)
+ return;
+ (*current_target.to_terminal_ours_for_output) (&current_target);
+ terminal_state = terminal_is_ours_for_output;
}
/* See target.h. */
diff --git a/gdb/target.h b/gdb/target.h
index f6175a0..874d873 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1383,31 +1383,25 @@ extern int target_remove_breakpoint (struct gdbarch *gdbarch,
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
-#define target_terminal_init() \
- (*current_target.to_terminal_init) (&current_target)
+extern void target_terminal_init (void);
/* Put the inferior's terminal settings into effect.
This is preparation for starting or resuming the inferior. */
extern void target_terminal_inferior (void);
-/* Put some of our terminal settings into effect,
- enough to get proper results from our output,
- but do not change into or out of RAW mode
- so that no input is discarded.
+/* Put some of our terminal settings into effect, enough to get proper
+ results from our output, but do not change into or out of RAW mode
+ so that no input is discarded. This is a no-op if terminal_ours
+ was most recently called. */
- After doing this, either terminal_ours or terminal_inferior
- should be called to get back to a normal state of affairs. */
-
-#define target_terminal_ours_for_output() \
- (*current_target.to_terminal_ours_for_output) (&current_target)
+extern void target_terminal_ours_for_output (void);
/* Put our terminal settings into effect.
First record the inferior's terminal settings
so they can be restored properly later. */
-#define target_terminal_ours() \
- (*current_target.to_terminal_ours) (&current_target)
+extern void target_terminal_ours (void);
/* Return true if the target stack has a non-default
"to_terminal_ours" method. */
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 754a2d1..0f98793 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1741,7 +1741,7 @@ do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching)
current thread until we report an event out of windows_wait. */
inferior_ptid = pid_to_ptid (pid);
- child_terminal_init_with_pgrp (pid);
+ target_terminal_init ();
target_terminal_inferior ();
windows_initialization_done = 0;