binutils-gdb/gdb/testsuite/lib
Pedro Alves 3eb7562a98 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.
2016-08-09 22:50:45 +01:00
..
ada.exp Remove extra output directory level for Ada tests 2016-07-06 10:03:15 -04:00
append_gdb_boards_dir.exp
build-piece.exp
cache.exp
cell.exp
cl_util.c
cl_util.h
compiler.c testsuite: Support detection of Intel compilers via test_compiler_version. 2016-04-18 13:52:43 +02:00
compiler.cc testsuite: Support detection of Intel compilers via test_compiler_version. 2016-04-18 13:52:43 +02:00
cp-support.exp
d-support.exp
dtrace.exp
dwarf.exp PR symtab/19999 gdb unable to resolve vars with fission+PIE 2016-05-12 09:24:24 -07:00
fortran.exp fortran: Testsuite, fix different type naming across compilers. 2016-04-18 14:04:07 +02:00
future.exp Update gdb test suite for Rust 2016-05-17 12:02:01 -06:00
gdb-guile.exp
gdb-python.exp
gdb-utils.exp
gdb.exp Extend JIT-reader test and fix GDB problems that exposes 2016-07-01 11:56:39 +01:00
gdbserver-support.exp Skip gdb.server/ tests if lack of XML support 2016-07-21 09:24:44 +01:00
gen-perf-test.exp
go.exp
java.exp
mi-support.exp Fix PR gdb/20418 - Problems with synchronous commands and new-ui 2016-08-09 22:50:45 +01:00
objc.exp
opencl.exp
opencl_hostapp.c
opencl_kernel.cl
pascal.exp
pdtrace.in
perftest.exp
prelink-support.exp
prompt.exp
range-stepping-support.exp
read1.c
rust-support.exp Update gdb test suite for Rust 2016-05-17 12:02:01 -06:00
selftest-support.exp Match the selftest output when captured_main is inlined 2016-07-12 15:39:34 +01:00
set_unbuffered_mode.c
trace-support.exp
unbuffer_output.c