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/event-top.c | |
parent | 7c36c34e4c5c9438f17373a72773d741a17dc7b3 (diff) | |
download | gdb-f38d3ad186f1820596743a04b7394b0749942501.zip gdb-f38d3ad186f1820596743a04b7394b0749942501.tar.gz gdb-f38d3ad186f1820596743a04b7394b0749942501.tar.bz2 |
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/event-top.c')
-rw-r--r-- | gdb/event-top.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/gdb/event-top.c b/gdb/event-top.c index 63f6896..3e2f778 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -510,7 +510,7 @@ stdin_event_handler (int error, gdb_client_data client_data) printf_unfiltered (_("error detected on stdin\n")); delete_file_handler (input_fd); /* If stdin died, we may as well kill gdb. */ - quit_command ((char *) 0, stdin == instream); + quit_command ((char *) 0, stdin == ui->instream); } else { @@ -566,10 +566,11 @@ async_disable_stdin (void) void command_handler (char *command) { + struct ui *ui = current_ui; struct cleanup *stat_chain; char *c; - if (instream == stdin) + if (ui->instream == stdin) reinitialize_more_filter (); stat_chain = make_command_stats_cleanup (1); @@ -579,7 +580,7 @@ command_handler (char *command) ; if (c[0] != '#') { - execute_command (command, instream == stdin); + execute_command (command, ui->instream == stdin); /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); @@ -646,6 +647,7 @@ char * handle_line_of_input (struct buffer *cmd_line_buffer, char *rl, int repeat, char *annotation_suffix) { + struct ui *ui = current_ui; char *p1; char *cmd; @@ -660,7 +662,7 @@ handle_line_of_input (struct buffer *cmd_line_buffer, command, but leave ownership of memory to the buffer . */ cmd_line_buffer->used_size = 0; - if (annotation_level > 1 && instream == stdin) + if (annotation_level > 1 && ui->instream == stdin) { printf_unfiltered (("\n\032\032post-")); puts_unfiltered (annotation_suffix); @@ -677,8 +679,8 @@ handle_line_of_input (struct buffer *cmd_line_buffer, } /* Do history expansion if that is wished. */ - if (history_expansion_p && instream == stdin - && ISATTY (instream)) + if (history_expansion_p && ui->instream == stdin + && ISATTY (ui->instream)) { char *history_value; int expanded; @@ -748,9 +750,11 @@ void command_line_handler (char *rl) { struct buffer *line_buffer = get_command_line_buffer (); + struct ui *ui = current_ui; char *cmd; - cmd = handle_line_of_input (line_buffer, rl, instream == stdin, "prompt"); + cmd = handle_line_of_input (line_buffer, rl, ui->instream == stdin, + "prompt"); if (cmd == (char *) EOF) { /* stdin closed. The connection with the terminal is gone. @@ -758,7 +762,7 @@ command_line_handler (char *rl) hung up but GDB is still alive. In such a case, we just quit gdb killing the inferior program too. */ printf_unfiltered ("quit\n"); - execute_command ("quit", stdin == instream); + execute_command ("quit", stdin == ui->instream); } else if (cmd == NULL) { @@ -793,9 +797,9 @@ gdb_readline_no_editing_callback (gdb_client_data client_data) stream after '\n'. If we buffer the input and fgetc drains the stream, getting stuff beyond the newline as well, a select, done afterwards will not trigger. */ - if (!done_once && !ISATTY (instream)) + if (!done_once && !ISATTY (ui->instream)) { - setbuf (instream, NULL); + setbuf (ui->instream, NULL); done_once = 1; } @@ -811,7 +815,7 @@ gdb_readline_no_editing_callback (gdb_client_data client_data) { /* Read from stdin if we are executing a user defined command. This is the right thing for prompt_for_continue, at least. */ - c = fgetc (instream ? instream : stdin); + c = fgetc (ui->instream ? ui->instream : stdin); if (c == EOF) { @@ -1059,7 +1063,7 @@ interruptible_select (int n, static void async_sigterm_handler (gdb_client_data arg) { - quit_force (NULL, stdin == instream); + quit_force (NULL, stdin == current_ui->instream); } /* See defs.h. */ @@ -1241,7 +1245,7 @@ gdb_setup_readline (void) /* If the input stream is connected to a terminal, turn on editing. */ - if (ISATTY (instream)) + if (ISATTY (ui->instream)) { /* Tell gdb that we will be using the readline library. This could be overwritten by a command in .gdbinit like 'set @@ -1264,11 +1268,11 @@ gdb_setup_readline (void) ui->input_handler = command_line_handler; /* Tell readline to use the same input stream that gdb uses. */ - rl_instream = instream; + rl_instream = ui->instream; /* Get a file descriptor for the input stream, so that we can register it with the event loop. */ - input_fd = fileno (instream); + input_fd = fileno (ui->instream); /* Now we need to create the event sources for the input file descriptor. */ |