diff options
author | Pedro Alves <palves@redhat.com> | 2016-08-22 11:58:58 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-08-22 14:37:53 +0100 |
commit | f11ce889cead9d9a6c68a499a7b900898bc2bbb8 (patch) | |
tree | ee5534b35ed767a778c9eeb4ce79b4df2a696fb2 | |
parent | 888a7fc3665a67e20da1bce2f865b0ff9ef15842 (diff) | |
download | binutils-gdb-users/palves/pr20494-no-input-after-start.tar.gz |
Fix PR20494users/palves/pr20494-no-input-after-start
-rw-r--r-- | gdb/inflow.c | 60 | ||||
-rw-r--r-- | gdb/terminal.h | 4 | ||||
-rw-r--r-- | gdb/top.c | 2 |
3 files changed, 21 insertions, 45 deletions
diff --git a/gdb/inflow.c b/gdb/inflow.c index 27ce0b04358..74c08fc77a7 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -136,61 +136,37 @@ gdb_getpgrp (void) } #endif -enum gdb_has_a_terminal_flag_enum - { - yes, no, have_not_checked - } -gdb_has_a_terminal_flag = have_not_checked; - -/* Set the initial tty state that is to be inherited by new inferiors. */ +/* See terminal.h. */ void set_initial_gdb_ttystate (void) { initial_gdb_ttystate = serial_get_tty_state (stdin_serial); -} - -/* Does GDB have a terminal (on stdin)? */ -int -gdb_has_a_terminal (void) -{ - switch (gdb_has_a_terminal_flag) - { - case yes: - return 1; - case no: - return 0; - case have_not_checked: - /* Get all the current tty settings (including whether we have a - tty at all!). Can't do this in _initialize_inflow because - serial_fdopen() won't work until the serial_ops_list is - initialized. */ + /* Get all the current tty settings (including whether we have a tty + at all!). Can't do this in _initialize_inflow because + serial_fdopen() won't work until the serial_ops_list is + initialized. */ #ifdef F_GETFL - our_terminal_info.tflags = fcntl (0, F_GETFL, 0); + our_terminal_info.tflags = fcntl (0, F_GETFL, 0); #endif - - gdb_has_a_terminal_flag = no; - if (stdin_serial != NULL) - { - our_terminal_info.ttystate = serial_get_tty_state (stdin_serial); - - if (our_terminal_info.ttystate != NULL) - { - gdb_has_a_terminal_flag = yes; + our_terminal_info.ttystate = serial_get_tty_state (stdin_serial); + if (our_terminal_info.ttystate != NULL) + { #ifdef PROCESS_GROUP_TYPE - our_terminal_info.process_group = gdb_getpgrp (); + our_terminal_info.process_group = gdb_getpgrp (); #endif - } - } - - return gdb_has_a_terminal_flag == yes; - default: - /* "Can't happen". */ - return 0; } } +/* Does GDB have a terminal (on stdin)? */ + +static int +gdb_has_a_terminal (void) +{ + return initial_gdb_ttystate != NULL; +} + /* Macro for printing errors from ioctl operations */ #define OOPSY(what) \ diff --git a/gdb/terminal.h b/gdb/terminal.h index 4a00716f150..0deced4535a 100644 --- a/gdb/terminal.h +++ b/gdb/terminal.h @@ -99,10 +99,10 @@ extern int gdb_setpgid (void); /* Set up a serial structure describing standard input. In inflow.c. */ extern void initialize_stdin_serial (void); -extern int gdb_has_a_terminal (void); - extern void gdb_save_tty_state (void); +/* Take a snapshot of our initial tty state before readline/ncurses + have had a chance to alter it. */ extern void set_initial_gdb_ttystate (void); /* Set the process group of the caller to its own pid, or do nothing diff --git a/gdb/top.c b/gdb/top.c index 36c300e8ce1..bc44192b8ad 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1719,7 +1719,7 @@ show_interactive_mode (struct ui_file *file, int from_tty, if (interactive_mode == AUTO_BOOLEAN_AUTO) fprintf_filtered (file, "Debugger's interactive mode " "is %s (currently %s).\n", - value, gdb_has_a_terminal () ? "on" : "off"); + value, input_interactive_p (current_ui) ? "on" : "off"); else fprintf_filtered (file, "Debugger's interactive mode is %s.\n", value); } |