[PATCH v2 13/25] Always process target events in the main UI

Pedro Alves
2016-03-21T15:21:38Z

This makes target events always be always processed with the main UI
as current UI. This way, warnings, debug output, etc. are always
consistently sent to the main console.
---
gdb/event-top.c | 2 +-
gdb/infrun.c | 6 ++++++
gdb/top.h | 2 ++
3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/event-top.c b/gdb/event-top.c
index 964edff..63f15c5 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -376,7 +376,7 @@ struct ui *main_ui = &main_ui_;
struct ui *current_ui = &main_ui_;
struct ui *ui_list = &main_ui_;

-static void
+void
restore_ui_cleanup (void *data)
{
current_ui = (struct ui *) data;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index cfd072b..b6524068 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3868,6 +3868,12 @@ fetch_inferior_event (void *client_data)

memset (ecs, 0, sizeof (*ecs));

+ /* Events are always processed with the main UI as current UI. This
+ way, warnings, debug output, etc. are always consistently sent to
+ the main console. */
+ make_cleanup (restore_ui_cleanup, current_ui);
+ current_ui = main_ui;
+
/* End up with readline processing input, if necessary. */
make_cleanup (reinstall_readline_callback_handler_cleanup, NULL);

diff --git a/gdb/top.h b/gdb/top.h
index 5967d73..de396a6 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -128,6 +128,8 @@ extern void switch_thru_all_uis_next (struct switch_thru_all_uis *state);
switch_thru_all_uis_cond (&STATE); \
switch_thru_all_uis_next (&STATE)) \

+extern void restore_ui_cleanup (void *data);
+
/* From top.c. */
extern char *saved_command_line;
extern int in_user_command;
--
2.5.0