+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * mi/mi-interp.c (display_mi_prompt): New function.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * target.c (target_terminal_inferior): Bail out after
+ unregistering input_fd if not on the main UI.
+ (target_terminal_ours): Bail out after registering input_fd if not
+ on the main UI.
+ (target_terminal_ours_for_output): Bail out if not on the main UI.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * event-top.c (restore_ui_cleanup): Make extern.
+ * infrun.c (fetch_inferior_event): Always switch to the main UI.
+ * top.h (restore_ui_cleanup): Declare.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ PR mi/20034
+ * cli/cli-interp.c: Include cli-interp.h and event-top.h.
+ (cli_interpreter_resume): Pass 1 to gdb_setup_readline. Set the
+ UI's input_handler here.
+ (cli_interpreter_supports_command_editing): New function.
+ (cli_interp_procs): Install it.
+ * cli/cli-interp.h: New file.
+ * event-top.c (async_command_editing_p): Rename to ...
+ (set_editing_cmd_var): ... this.
+ (change_line_handler): Add parameter 'editing', and use it. Bail
+ early if the interpreter doesn't support editing. Don't touch
+ readline state if editing is off.
+ (gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install)
+ (gdb_rl_callback_handler_reinstall): Assert the current UI is the
+ main UI.
+ (display_gdb_prompt): Don't call gdb_rl_callback_handler_remove if
+ not using readline. Check whether the current UI is using command
+ editing instead of checking the async_command_editing_p global.
+ (set_async_editing_command): Delete.
+ (gdb_setup_readline): Add 'editing' parameter. Only allow editing
+ on the main UI. Don't touch readline state if editing is off.
+ (gdb_disable_readline): Don't touch readline state if editing is
+ off.
+ * event-top.h (gdb_setup_readline): Add 'int' parameter.
+ (set_async_editing_command): Delete declaration.
+ (change_line_handler, command_line_handler): Declare.
+ (async_command_editing_p): Rename to ...
+ (set_editing_cmd_var): ... this.
+ * infrun.c (reinstall_readline_callback_handler_cleanup): Check
+ whether the current UI has editing enabled rather than checking
+ the async_command_editing_p global.
+ * interps.c (interp_supports_command_editing): New function.
+ * interps.h (interp_supports_command_editing_ftype): New typedef.
+ (struct interp_procs) <supports_command_editing_proc>: New field.
+ (interp_supports_command_editing): Declare.
+ * mi/mi-interp.c (mi_interpreter_resume): Pass 0 to
+ gdb_setup_readline. Don't clear the async_command_editing_p
+ global. Update comments.
+ * top.c (gdb_readline_wrapper_line, gdb_readline_wrapper): Check
+ whether the current UI has editing enabled rather than checking
+ the async_command_editing_p global. Don't touch readline state if
+ editing is off.
+ (undo_terminal_modifications_before_exit): Switch to the main UI.
+ Unconditionally call gdb_disable_readline.
+ (set_editing): New function.
+ (show_async_command_editing_p): Rename to ...
+ (show_editing): ... this. Show the state of the current UI.
+ (_initialize_top): Adjust.
+ * top.h (struct ui) <command_editing>: New field.
+ * tui/tui-interp.c: Include cli/cli-interp.h.
+ (tui_resume): Pass 1 to gdb_setup_readline. Set the UI's
+ input_handler.
+ (tui_interp_procs): Install
+ cli_interpreter_supports_command_editing.
+ * tui/tui-io.c (tui_getc): Check whether the current UI has
+ editing enabled rather than checking the async_command_editing_p
+ global.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * top.c: Call gen_ret_current_ui_field_ptr for current_uiout.
+ * top.h (struct ui) <m_current_uiout>: New field.
+ * ui-out.c (current_uiout): Delete.
+ * ui-out.h (current_uiout): Delete.
+ (current_ui_current_uiout_ptr): New declaration.
+ (current_uiout): Reimplement as wrapper around
+ current_ui_current_uiout_ptr.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * ui-out.c (default_ui_out_impl): Delete.
+ (def_uiout): Delete.
+ (current_uiout): Set to NULL.
+ (default_table_begin, default_table_body, default_table_end)
+ (default_table_header, default_begin, default_end)
+ (default_field_int, default_field_skip, default_field_string)
+ (default_field_fmt, default_spaces, default_text, default_message)
+ (default_wrap_hint, default_flush, default_data_destroy): Delete.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * event-top.c (gdb_setup_readline): Pass the UI's outstream and
+ errstream to stdout_fileopen and stderr_fileopen.
+ * exceptions.c: Include top.h.
+ (print_flush): Open the current UI's outstream file descriptor,
+ instead of hardcoding file descriptor 1.
+ * main.c (captured_main): Save the main UI's out and error
+ streams. Adjust stderr_fileopen call.
+ * top.h (struct ui) <outstream, errstream>: New fields.
+ * ui-file.c (stderr_fileopen): Add stream parameter. Use it
+ instead of stderr.
+ * ui-file.h (stderr_fileopen): Add stream parameter and update
+ comment.
+
+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.
+
+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.
+ (as_cli_interp): New function.
+ (cli_on_normal_stop, cli_on_signal_received)
+ (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
+ (cli_on_no_history): Send output to all CLI UIs.
+ (cli_on_sync_execution_done, cli_on_command_error): Skip output if
+ the top level interpreter is not a CLI.
+ (cli_interpreter_init): Don't set cli_interp or install observers
+ here.
+ (_initialize_cli_interp): Install observers here.
+ * event-top.c (main_ui_, ui_list): New globals.
+ (current_ui): Point to main_ui_.
+ (restore_ui_cleanup, switch_thru_all_uis_init)
+ (switch_thru_all_uis_cond, switch_thru_all_uis_next): New
+ functions.
+ * mi/mi-interp.c (as_mi_interp): New function.
+ (mi_interpreter_init): Don't install observers here.
+ (mi_on_sync_execution_done): Skip output if the top level
+ interpreter is not a MI.
+ (mi_new_thread, mi_thread_exit, mi_record_changed)
+ (mi_inferior_added, mi_inferior_appeared, mi_inferior_exit)
+ (mi_inferior_removed): Send output to all MI UIs.
+ (find_mi_interpreter, mi_interp_data): Delete.
+ (find_mi_interp): New function.
+ (mi_on_signal_received, mi_on_end_stepping_range)
+ (mi_on_signal_exited, mi_on_exited, mi_on_no_history): Send output
+ to all MI UIs.
+ (mi_on_normal_stop): Rename to ...
+ (mi_on_normal_stop_1): ... this.
+ (mi_on_normal_stop): Reimplement, sending output to all MI UIs.
+ (mi_traceframe_changed, mi_tsv_created, mi_tsv_deleted)
+ (mi_tsv_modified, mi_breakpoint_created, mi_breakpoint_deleted)
+ (mi_breakpoint_modified, mi_output_running_pid): Send output to
+ all MI UIs.
+ (mi_on_resume): Rename to ...
+ (mi_on_resume_1): ... this. Don't handle infcalls here.
+ (mi_on_resume): Reimplement, sending output to all MI UIs.
+ (mi_solib_loaded, mi_solib_unloaded, mi_command_param_changed)
+ (mi_memory_changed): Send output to all MI UIs.
+ (report_initial_inferior): Install observers here.
+ * top.h (struct ui) <next>: New field.
+ (ui_list): Declare.
+ (struct switch_thru_all_uis): New.
+ (switch_thru_all_uis_init, switch_thru_all_uis_cond)
+ (switch_thru_all_uis_next): Declare.
+ (SWITCH_THRU_ALL_UIS): New macro.
+ * tui/tui-interp.c (tui_interp): Delete global.
+ (as_tui_interp): New function.
+ (tui_on_normal_stop, tui_on_signal_received)
+ (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited)
+ (tui_on_no_history): Send output to all TUI UIs.
+ (tui_on_sync_execution_done, tui_on_command_error): Skip output if
+ the top level interpreter is not a TUI.
+ (tui_init): Don't set tui_interp or install observers here.
+ (_initialize_tui_interp): Install observers here.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * cli/cli-interp.c (cli_uiout): Delete, moved into ...
+ (struct cli_interp): ... this new structure.
+ (cli_on_normal_stop, cli_on_signal_received)
+ (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited)
+ (cli_on_no_history): Use interp_ui_out.
+ (cli_interpreter_init): If top level, set the cli_interp global.
+ (cli_interpreter_init): Return the interp's data instead of NULL.
+ (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust
+ to cli_uiout being in the interpreter's data.
+ (cli_interp_procs): New, factored out from _initialize_cli_interp.
+ (cli_interp_factory): New function.
+ (_initialize_cli_interp): Call interp_factory_register.
+ * interps.c (get_interp_info): New, factored out from ...
+ (get_current_interp_info): ... this.
+ (interp_new): Add parameter 'data'. Store it.
+ (struct interp_factory): New function.
+ (interp_factory_p): New typedef. Define a VEC_P.
+ (interpreter_factories): New global.
+ (interp_factory_register): New function.
+ (interp_add): Add 'ui' parameter. Use get_interp_info and
+ interp_lookup_existing.
+ (interp_lookup): Rename to ...
+ (interp_lookup_existing): ... this. Add 'ui' parameter. Don't
+ check for NULL or empty name here.
+ (interp_lookup): Add 'ui' parameter and reimplement.
+ (interp_set_temp, interpreter_exec_cmd): Adjust.
+ (interpreter_completer): Complete on registered interpreter
+ factories instead of interpreters.
+ * interps.h (interp_factory_func): New typedef.
+ (interp_factory_register): Declare.
+ (interp_new, interp_add): Adjust.
+ (interp_lookup): Declare.
+ * main.c (captured_main): Adjust.
+ * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust.
+ (mi_interp_procs): New, factored out from
+ _initialize_mi_interp.
+ (mi_interp_factory): New function.
+ * python/python.c (execute_gdb_command): Adjust.
+ * tui/tui-interp.c (tui_init): If top level, set the tui_interp
+ global.
+ (tui_interp_procs): New.
+ (tui_interp_factory): New function.
+ (_initialize_tui_interp): Call interp_factory_register.
+
+2016-06-21 Pedro Alves <palves@redhat.com>
+
+ * breakpoint.c (bpstat_do_actions_1): Access the current UI's
+ async field instead of the interpreter_async global.
+ * cli/cli-script.c (execute_user_command, while_command)
+ (if_command, script_from_file): Likewise.
+ * compile/compile.c: Include top.h instead of interps.h.
+ (compile_file_command, compile_code_command)
+ (compile_print_command): Access the current UI's async field
+ instead of the interpreter_async global.
+ * guile/guile.c: Include top.h instead of interps.h.
+ (guile_repl_command, guile_command, gdbscm_execute_gdb_command):
+ Access the current UI's async field instead of the
+ interpreter_async global.
+ * guile/scm-ports.c: Include top.h instead of interps.h.
+ (ioscm_with_output_to_port_worker): Access the current UI's async
+ field instead of the interpreter_async global.
+ * inf-loop.c (inferior_event_handler): Likewise.
+ * infcall.c (run_inferior_call): Likewise.
+ * infrun.c (reinstall_readline_callback_handler_cleanup)
+ (fetch_inferior_event): Likewise.
+ * interps.c (interpreter_async): Delete.
+ (struct ui_interp_info): New.
+ (get_current_interp_info): New function.
+ (interp_list, current_interpreter, top_level_interpreter_ptr):
+ Delete.
+ (interp_add, interp_set, interp_lookup, interp_ui_out)
+ (current_interp_set_logging, interp_set_temp)
+ (current_interp_named_p): Adjust to per-UI interpreters.
+ (command_interpreter): Delete.
+ (command_interp, current_interp_command_loop, interp_quiet_p)
+ (interp_exec, interpreter_exec_cmd, interpreter_completer)
+ (top_level_interpreter, top_level_interpreter_data): Adjust to
+ per-UI interpreters.
+ * interps.h (interpreter_async): Delete.
+ * main.c (captured_command_loop): Access the current UI's async
+ field instead of the interpreter_async global.
+ * python/python.c (python_interactive_command, python_command)
+ (execute_gdb_command): Likewise.
+ * top.c (maybe_wait_sync_command_done, execute_command_to_string):
+ Access the current UI's async field instead of the
+ interpreter_async global.
+ * top.h (struct tl_interp_info): Forward declare.
+ (struct ui) <interp_info, async>: New fields.
+
2016-06-21 Pedro Alves <palves@redhat.com>
* main.c (gdb_stdout, gdb_stderr, gdb_stdlog, gdb_stdin): Delete