aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-06-21 01:11:45 +0100
committerPedro Alves <palves@redhat.com>2016-06-21 01:11:45 +0100
commit73ab01a07dfef77a9d845be2ef87754435eeffa1 (patch)
treeecedd002b69377c16f0e6e78a0cec7e6eb4ae39a /gdb/top.h
parent8322445e0584be846f5873b9aab257dc9fbda05d (diff)
downloadgdb-73ab01a07dfef77a9d845be2ef87754435eeffa1.zip
gdb-73ab01a07dfef77a9d845be2ef87754435eeffa1.tar.gz
gdb-73ab01a07dfef77a9d845be2ef87754435eeffa1.tar.bz2
Make the intepreters output to all UIs
When we have multiple consoles, MI channels, etc., then we need to broadcast breakpoint hits, etc. to all UIs. In the past, I've adjusted most of the run control to communicate events to the interpreters through observer notifications, so events would be properly sent to console and MI streams, in sync and async modes. This patch does the next logical step -- have each interpreter's observers output interpreter-specific info to _all_ UIs. Note that when we have multiple instances of active cli/tui interpreters, then the cli_interp and tui_interp globals no longer work. This is addressed by this patch. Also, the interpreters currently register some observers when resumed and remove them when suspended. If we have multiple instances of the interpreters, and they can be suspended/resumed at different, independent times, that no longer works. What we instead do is always install the observers, and then have the observers themselves know when to do nothing. An earlier prototype of this series did the looping over struct UIs in common code, and then dispatched events to the interpreters through a matching interp_on_foo method for each observer. That turned out a lot more complicated than the present solution, as we'd end up with having to create a new interp method every time some interpreter wanted to listen to some observer notification, resulting in a lot of duplicated make-work and more coupling than desirable. gdb/ChangeLog: 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.
Diffstat (limited to 'gdb/top.h')
-rw-r--r--gdb/top.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/top.h b/gdb/top.h
index f18b79e..80fcb40 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -36,6 +36,9 @@ struct tl_interp_info;
struct ui
{
+ /* Pointer to next in singly-linked list. */
+ struct ui *next;
+
/* The UI's command line buffer. This is to used to accumulate
input until we have a whole command line. */
struct buffer line_buffer;
@@ -83,8 +86,34 @@ struct ui
struct ui_file *m_gdb_stdlog;
};
+/* The current UI. */
extern struct ui *current_ui;
+/* The list of all UIs. */
+extern struct ui *ui_list;
+
+/* State for SWITCH_THRU_ALL_UIS. Declared here because it is meant
+ to be created on the stack, but should be treated as opaque. */
+struct switch_thru_all_uis
+{
+ struct ui *iter;
+ struct cleanup *old_chain;
+};
+
+/* Functions to drive SWITCH_THRU_ALL_UIS. Though declared here by
+ necessity, these functions should not be used other than via the
+ SWITCH_THRU_ALL_UIS macro defined below. */
+extern void switch_thru_all_uis_init (struct switch_thru_all_uis *state);
+extern int switch_thru_all_uis_cond (struct switch_thru_all_uis *state);
+extern void switch_thru_all_uis_next (struct switch_thru_all_uis *state);
+
+ /* Traverse through all UI, and switch the current UI to the one
+ being iterated. */
+#define SWITCH_THRU_ALL_UIS(STATE) \
+ for (switch_thru_all_uis_init (&STATE); \
+ switch_thru_all_uis_cond (&STATE); \
+ switch_thru_all_uis_next (&STATE))
+
/* From top.c. */
extern char *saved_command_line;
extern FILE *instream;