diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:46 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:46 +0100 |
commit | f38d3ad186f1820596743a04b7394b0749942501 (patch) | |
tree | ce355366594f63fa67ffa6354a9f37602e6a5865 /gdb/top.c | |
parent | 7c36c34e4c5c9438f17373a72773d741a17dc7b3 (diff) | |
download | binutils-gdb-f38d3ad186f1820596743a04b7394b0749942501.tar.gz |
Make instream be per UI
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* cli/cli-script.c (execute_user_command, read_next_line)
(read_next_line): Adjust to per-UI instream.
* event-top.c (stdin_event_handler, command_handler)
(handle_line_of_input, command_line_handler)
(gdb_readline_no_editing_callback, async_sigterm_handler)
(gdb_setup_readline): Likewise.
* inflow.c: Include top.h.
(gdb_has_a_terminal, child_terminal_init_with_pgrp)
(gdb_save_tty_state, child_terminal_inferior)
(child_terminal_ours_1, copy_terminal_info): Use the main UI.
(initialize_stdin_serial): Adjust to per-UI instream.
* main.c (captured_command_loop, captured_main): Adjust to per-UI
instream.
* mi/mi-interp.c (mi_execute_command_wrapper): Likewise.
* python/python.c (python_interactive_command): Likewise.
* terminal.h (struct ui): Forward declare.
(initialize_stdin_serial): Add struct ui parameter.
* top.c (instream): Delete.
(do_restore_instream_cleanup, read_command_file, dont_repeat)
(gdb_readline_no_editing, command_line_input)
(input_from_terminal_p, gdb_init): Adjust to per-UI instream.
* top.h (struct ui) <instream>: New field.
(instream): Delete declaration.
(quit): Adjust to per-UI instream.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* gdb.gdb/selftest.exp (do_steps_and_nexts): Add new regexp.
Diffstat (limited to 'gdb/top.c')
-rw-r--r-- | gdb/top.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/gdb/top.c b/gdb/top.c index 3842f0c57d0..733580f637b 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -123,13 +123,6 @@ show_confirm (struct ui_file *file, int from_tty, value); } -/* stdio stream that command input is being read from. Set to stdin - normally. Set by source_command to the file we are sourcing. Set - to NULL if we are executing a user-defined command or interacting - via a GUI. */ - -FILE *instream; - /* Flag to indicate whether a user defined command is currently running. */ int in_user_command; @@ -286,23 +279,26 @@ quit_cover (void) void do_restore_instream_cleanup (void *stream) { + struct ui *ui = current_ui; + /* Restore the previous input stream. */ - instream = (FILE *) stream; + ui->instream = (FILE *) stream; } /* Read commands from STREAM. */ void read_command_file (FILE *stream) { + struct ui *ui = current_ui; struct cleanup *cleanups; - cleanups = make_cleanup (do_restore_instream_cleanup, instream); - instream = stream; + cleanups = make_cleanup (do_restore_instream_cleanup, ui->instream); + ui->instream = stream; /* Read commands from `instream' and execute them until end of file or error reading instream. */ - while (instream != NULL && !feof (instream)) + while (ui->instream != NULL && !feof (ui->instream)) { char *command; @@ -568,13 +564,15 @@ static int suppress_dont_repeat = 0; void dont_repeat (void) { + struct ui *ui = current_ui; + if (suppress_dont_repeat || server_command) return; /* If we aren't reading from standard input, we are saving the last thing read from stdin in line and don't want to delete it. Null lines won't repeat here in any case. */ - if (instream == stdin) + if (ui->instream == stdin) *saved_command_line = 0; } @@ -603,9 +601,10 @@ static char * gdb_readline_no_editing (const char *prompt) { struct buffer line_buffer; + struct ui *ui = current_ui; /* Read from stdin if we are executing a user defined command. This is the right thing for prompt_for_continue, at least. */ - FILE *stream = instream != NULL ? instream : stdin; + FILE *stream = ui->instream != NULL ? ui->instream : stdin; int fd = fileno (stream); buffer_init (&line_buffer); @@ -1047,6 +1046,7 @@ command_line_input (const char *prompt_arg, int repeat, char *annotation_suffix) { static struct buffer cmd_line_buffer; static int cmd_line_buffer_initialized; + struct ui *ui = current_ui; const char *prompt = prompt_arg; char *cmd; @@ -1054,7 +1054,7 @@ command_line_input (const char *prompt_arg, int repeat, char *annotation_suffix) if (annotation_suffix == NULL) annotation_suffix = ""; - if (annotation_level > 1 && instream == stdin) + if (annotation_level > 1 && ui->instream == stdin) { char *local_prompt; @@ -1100,7 +1100,7 @@ command_line_input (const char *prompt_arg, int repeat, char *annotation_suffix) if (source_file_name != NULL) ++source_line_number; - if (annotation_level > 1 && instream == stdin) + if (annotation_level > 1 && ui->instream == stdin) { puts_unfiltered ("\n\032\032pre-"); puts_unfiltered (annotation_suffix); @@ -1511,16 +1511,18 @@ quit_force (char *args, int from_tty) int input_from_terminal_p (void) { + struct ui *ui = current_ui; + if (batch_flag) return 0; - if (gdb_has_a_terminal () && instream == stdin) + if (gdb_has_a_terminal () && ui->instream == stdin) return 1; /* If INSTREAM is unset, and we are not in a user command, we must be in Insight. That's like having a terminal, for our purposes. */ - if (instream == NULL && !in_user_command) + if (ui->instream == NULL && !in_user_command) return 1; return 0; |