+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.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * event-loop.c: Include top.h.
+ (invoke_async_signal_handlers): Switch to the main UI.
+ * event-top.c (main_ui_): Update comment.
+ (main_ui): New global.
+ * top.h (main_ui): Declare.
+
2016-06-21 Pedro Alves <palves@redhat.com>
* cli/cli-interp.c (cli_interp): Delete.
void
execute_user_command (struct cmd_list_element *c, char *args)
{
+ struct ui *ui = current_ui;
struct command_line *cmdlines;
struct cleanup *old_chain;
enum command_control_type ret;
/* Set the instream to 0, indicating execution of a
user-defined function. */
- make_cleanup (do_restore_instream_cleanup, instream);
- instream = (FILE *) 0;
+ make_cleanup (do_restore_instream_cleanup, ui->instream);
+ ui->instream = NULL;
/* Also set the global in_user_command, so that NULL instream is
not confused with Insight. */
static char *
read_next_line (void)
{
+ struct ui *ui = current_ui;
char *prompt_ptr, control_prompt[256];
int i = 0;
error (_("Control nesting too deep!"));
/* Set a prompt based on the nesting of the control commands. */
- if (instream == stdin || (instream == 0 && deprecated_readline_hook != NULL))
+ if (ui->instream == stdin
+ || (ui->instream == 0 && deprecated_readline_hook != NULL))
{
for (i = 0; i < control_level; i++)
control_prompt[i] = ' ';
else
prompt_ptr = NULL;
- return command_line_input (prompt_ptr, instream == stdin, "commands");
+ return command_line_input (prompt_ptr, ui->instream == stdin, "commands");
}
/* Process one input line. If the command is an "end", return such an
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
{
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);
;
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 ();
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;
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);
}
/* 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;
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.
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)
{
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;
}
{
/* 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)
{
static void
async_sigterm_handler (gdb_client_data arg)
{
- quit_force (NULL, stdin == instream);
+ quit_force (NULL, stdin == current_ui->instream);
}
/* See defs.h. */
/* 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
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. */
static int
captured_command_loop (void *data)
{
+ struct ui *ui = current_ui;
+
/* Top-level execution commands can be run in the background from
here on. */
current_ui->async = 1;
error) we try to quit. If the quit is aborted, catch_errors()
which called this catch the signal and restart the command
loop. */
- quit_command (NULL, instream == stdin);
+ quit_command (NULL, ui->instream == stdin);
return 1;
}
static int
captured_main (void *data)
{
+ struct ui *ui = current_ui;
struct captured_main_args *context = (struct captured_main_args *) data;
int argc = context->argc;
char **argv = context->argv;
ndir = 0;
saved_command_line = (char *) xstrdup ("");
- instream = stdin;
+ ui->instream = stdin;
#ifdef __MINGW32__
/* Ensure stderr is unbuffered. A Cygwin pty or pipe is implemented
static void
mi_execute_command_wrapper (const char *cmd)
{
- mi_execute_command (cmd, stdin == instream);
+ struct ui *ui = current_ui;
+
+ mi_execute_command (cmd, stdin == ui->instream);
}
/* Observer for the synchronous_command_done notification. */
static void
python_interactive_command (char *arg, int from_tty)
{
+ struct ui *ui = current_ui;
struct cleanup *cleanup;
int err;
}
else
{
- err = PyRun_InteractiveLoop (instream, "<stdin>");
+ err = PyRun_InteractiveLoop (ui->instream, "<stdin>");
dont_repeat ();
}
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * gdb.gdb/selftest.exp (do_steps_and_nexts): Add new regexp.
+
2016-06-21 Pedro Alves <palves@redhat.com>
* gdb.ada/mi_catch_ex.exp (continue_to_exception): New procedure.
set description "step over gdb_stderr initialization"
set command "step"
}
+ -re "ui = current_ui.*$gdb_prompt $" {
+ set description "step over top_level initialization"
+ set command "step"
+ }
-re ".*main.c.*No such file or directory.*$gdb_prompt $" {
setup_xfail "rs6000-*-aix3*"
fail "must be able to list source lines"
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;
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;
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;
}
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);
{
static struct buffer cmd_line_buffer;
static int cmd_line_buffer_initialized;
+ struct ui *ui = current_ui;
const char *prompt = prompt_arg;
char *cmd;
if (annotation_suffix == NULL)
annotation_suffix = "";
- if (annotation_level > 1 && instream == stdin)
+ if (annotation_level > 1 && ui->instream == stdin)
{
char *local_prompt;
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);
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;
"start" -ex "next"') are processed. */
int async;
+ /* 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;
+
/* The fields below that start with "m_" are "private". They're
meant to be accessed through wrapper macros that make them look
like globals. */
/* From top.c. */
extern char *saved_command_line;
-extern FILE *instream;
extern int in_user_command;
extern int confirm;
extern char gdb_dirbuf[1024];
void
quit (void)
{
+ struct ui *ui = current_ui;
+
if (sync_quit_force_run)
{
sync_quit_force_run = 0;
- quit_force (NULL, stdin == instream);
+ quit_force (NULL, stdin == ui->instream);
}
#ifdef __MSDOS__