summaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-08-09 22:45:40 +0100
committerPedro Alves <palves@redhat.com>2016-08-09 22:50:45 +0100
commit3eb7562a983bab4c768983bcd85708852d171121 (patch)
tree9ceb489cbd1f48967e11a4a60d1f34d9b57ec007 /gdb/target.h
parent80614914274f7166baea2ec656aec6a949869324 (diff)
Fix PR gdb/20418 - Problems with synchronous commands and new-ui
When executing commands on a secondary UI running the MI interpreter, some commands that should be synchronous are not. MI incorrectly continues processing input right after the synchronous command is sent, before the target stops. The problem happens when we emit MI async events (=library-loaded, etc.), and we go about restoring the previous terminal state, we end up calling target_terminal_ours, which incorrectly always installs the current UI's input_fd in the event loop... That is, code like this: old_chain = make_cleanup_restore_target_terminal (); target_terminal_ours_for_output (); fprintf_unfiltered (mi->event_channel, "library-loaded"); ... do_cleanups (old_chain); The fix is to move the add_file_handler/delete_file_handler calls out of target_terminal_$foo, making these completely no-ops unless called with the main UI as current UI. gdb/ChangeLog: 2016-08-09 Pedro Alves <palves@redhat.com> PR gdb/20418 * event-top.c (ui_register_input_event_handler) (ui_unregister_input_event_handler): New functions. (async_enable_stdin): Register input in the event loop. (async_disable_stdin): Unregister input from the event loop. (gdb_setup_readline): Register input in the event loop. * infrun.c (check_curr_ui_sync_execution_done): Register input in the event loop. * target.c (target_terminal_inferior): Don't unregister input from the event loop. (target_terminal_ours): Don't register input in the event loop. * target.h (target_terminal_inferior) (target_terminal_ours_for_output, target_terminal_ours): Update comments. * top.h (ui_register_input_event_handler) (ui_unregister_input_event_handler): New declarations. * utils.c (ui_unregister_input_event_handler_cleanup) (prepare_to_handle_input): New functions. (defaulted_query, prompt_for_continue): Use prepare_to_handle_input. gdb/testsuite/ChangeLog: 2016-08-09 Pedro Alves <palves@redhat.com> Simon Marchi <simon.marchi@ericsson.com> PR gdb/20418 * gdb.mi/new-ui-mi-sync.c, gdb.mi/new-ui-mi-sync.exp: New files. * lib/mi-support.exp (mi_expect_interrupt): Remove anchors.
Diffstat (limited to 'gdb/target.h')
-rw-r--r--gdb/target.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/gdb/target.h b/gdb/target.h
index 15fd806ad9..7091360260 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1523,21 +1523,23 @@ extern int target_terminal_is_ours (void);
extern void target_terminal_init (void);
-/* Put the inferior's terminal settings into effect.
- This is preparation for starting or resuming the inferior. */
+/* Put the inferior's terminal settings into effect. This is
+ preparation for starting or resuming the inferior. This is a no-op
+ unless called with the main UI as current UI. */
extern void target_terminal_inferior (void);
/* Put some of our terminal settings into effect, enough to get proper
results from our output, but do not change into or out of RAW mode
so that no input is discarded. This is a no-op if terminal_ours
- was most recently called. */
+ was most recently called. This is a no-op unless called with the main
+ UI as current UI. */
extern void target_terminal_ours_for_output (void);
-/* Put our terminal settings into effect.
- First record the inferior's terminal settings
- so they can be restored properly later. */
+/* Put our terminal settings into effect. First record the inferior's
+ terminal settings so they can be restored properly later. This is
+ a no-op unless called with the main UI as current UI. */
extern void target_terminal_ours (void);