aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-06-21 01:11:47 +0100
committerPedro Alves <palves@redhat.com>2016-06-21 01:11:47 +0100
commit41fd2b0f5d958fe3056da5c7af4032b1b99d726f (patch)
tree0b6cc80673dae6a9d7eadbe3a8422cb175fc437a /gdb/target.c
parentf38d3ad186f1820596743a04b7394b0749942501 (diff)
downloadgdb-41fd2b0f5d958fe3056da5c7af4032b1b99d726f.zip
gdb-41fd2b0f5d958fe3056da5c7af4032b1b99d726f.tar.gz
gdb-41fd2b0f5d958fe3056da5c7af4032b1b99d726f.tar.bz2
Make input_fd be per UI
And with that, we can switch the current UI to the UI whose input descriptor woke up the event loop. IOW, if the user types in UI 2, the event loop wakes up, switches to UI 2, and processes the input. Next the user types in UI 3, the event loop wakes up and switches to UI 3, etc. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * event-top.c (input_fd): Delete. (stdin_event_handler): Switch to the UI whose input descriptor got the event. Adjust to per-UI input_fd. (gdb_setup_readline): Don't set the input_fd global. Adjust to per-UI input_fd. (gdb_disable_readline): Adjust to per-UI input_fd. * event-top.h (input_fd): Delete declaration. * linux-nat.c (linux_nat_terminal_inferior): Don't remove input_fd from the event-loop here. (linux_nat_terminal_ours): Don't register input_fd in the event-loop here. * main.c (captured_main): Adjust to per-UI input_fd. * remote.c (remote_terminal_inferior): Don't remove input_fd from the event-loop here. (remote_terminal_ours): Don't register input_fd in the event-loop here. * target.c: Include top.h and event-top.h. (target_terminal_inferior): Remove input_fd from the event-loop here. (target_terminal_ours): Register input_fd in the event-loop. * top.h (struct ui) <input_fd>: New field.
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/target.c b/gdb/target.c
index c0ce46d..b53074a 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -43,6 +43,8 @@
#include "agent.h"
#include "auxv.h"
#include "target-debug.h"
+#include "top.h"
+#include "event-top.h"
static void target_info (char *, int);
@@ -477,6 +479,8 @@ target_terminal_is_ours (void)
void
target_terminal_inferior (void)
{
+ struct ui *ui = current_ui;
+
/* A background resume (``run&'') should leave GDB in control of the
terminal. Use target_can_async_p, not target_is_async_p, since at
this point the target is not async yet. However, if sync_execution
@@ -484,6 +488,11 @@ target_terminal_inferior (void)
if (target_can_async_p () && !sync_execution)
return;
+ /* Always delete the current UI's input file handler, regardless of
+ terminal_state, because terminal_state is only valid for the main
+ UI. */
+ delete_file_handler (ui->input_fd);
+
if (terminal_state == terminal_is_inferior)
return;
@@ -503,6 +512,13 @@ target_terminal_inferior (void)
void
target_terminal_ours (void)
{
+ struct ui *ui = current_ui;
+
+ /* Always add the current UI's input file handler, regardless of
+ terminal_state, because terminal_state is only valid for the main
+ UI. */
+ add_file_handler (ui->input_fd, stdin_event_handler, ui);
+
if (terminal_state == terminal_is_ours)
return;