gdb: Re-enable stdin for all UIs from start_event_loop

If we catch an exception in start_event_loop's call to
gdb_do_one_event, then it is possible that the current_ui has changed
since we called async_disable_stdin.  If that's the case then calling
async_enable_stdin will be called on the wrong UI.

To solve this problem we wrap the call to async_enable_stdin with
SWITCH_THRU_ALL_UIS, this causes us to try and re-enable stdin for all
UIs, which will catch any for which we called async_disable_stdin.

gdb/ChangeLog:

	* event-loop.c (start_event_loop): Wrap async_enable_stdin with
	SWITCH_THRU_ALL_UIS.

gdb/testsuite/ChangeLog:

	* gdb.server/multi-ui-errors.c: New file.
	* gdb.server/multi-ui-errors.exp: New file.

Change-Id: I1e18deff2e6f4e17f7a13adce3553eb001cad93b
This commit is contained in:
Andrew Burgess 2019-11-19 18:09:43 +00:00
parent 733d0a6795
commit f3364a6d0f
5 changed files with 153 additions and 1 deletions

View file

@ -376,7 +376,10 @@ start_event_loop (void)
/* If any exception escaped to here, we better enable
stdin. Otherwise, any command that calls async_disable_stdin,
and then throws, will leave stdin inoperable. */
async_enable_stdin ();
SWITCH_THRU_ALL_UIS ()
{
async_enable_stdin ();
}
/* If we long-jumped out of do_one_event, we probably didn't
get around to resetting the prompt, which leaves readline
in a messed-up state. Reset it here. */