]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Fix PR gdb/20418 - Problems with synchronous commands and new-ui
authorPedro Alves <palves@redhat.com>
Tue, 9 Aug 2016 21:52:46 +0000 (22:52 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 9 Aug 2016 21:52:46 +0000 (22:52 +0100)
commitb24bdfa398beba87b48fffeb3b1f9bcfe7bf924d
tree23f19afd14fe9df6f0eca50b60ac0d66bad1510e
parent4d38db46f6f6480ee33844164383ce40e5fc2440
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.
gdb/ChangeLog
gdb/event-top.c
gdb/infrun.c
gdb/target.c
gdb/target.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/new-ui-mi-sync.c [new file with mode: 0644]
gdb/testsuite/gdb.mi/new-ui-mi-sync.exp [new file with mode: 0644]
gdb/testsuite/lib/mi-support.exp
gdb/top.h
gdb/utils.c