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/ChangeLog:
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>
+
+       * 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
 
 struct ui *current_ui = &main_ui_;
 struct ui *ui_list = &main_ui_;
 
-/* Cleanup that restores the current UI.  */
+/* See top.h.  */
 
-static void
+void
 restore_ui_cleanup (void *data)
 {
   current_ui = (struct ui *) 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);
 
 
        switch_thru_all_uis_cond (&STATE);              \
        switch_thru_all_uis_next (&STATE))
 
+/* Cleanup that restores the current UI.  */
+extern void restore_ui_cleanup (void *data);
+
 /* From top.c.  */
 extern char *saved_command_line;
 extern int in_user_command;