Merge async and sync code paths some more

This patch makes the execution control code use largely the same
mechanisms in both sync- and async-capable targets.  This means using
continuations and use the event loop to react to target events on sync
targets as well.  The trick is to immediately mark infrun's event loop
source after resume instead of calling wait_for_inferior.  Then
fetch_inferior_event is adjusted to do a blocking wait on sync
targets.

Tested on x86_64 Fedora 20, native and gdbserver, with and without
"maint set target-async off".

gdb/ChangeLog:
2015-09-09  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (bpstat_do_actions_1, until_break_command): Don't
	check whether the target can async.
	* inf-loop.c (inferior_event_handler): Only call target_async if
	the target can async.
	* infcall.c: Include top.h and interps.h.
	(run_inferior_call): For the interpreter to sync mode while
	running the infcall.  Call wait_sync_command_done instead of
	wait_for_inferior plus normal_stop.
	* infcmd.c (prepare_execution_command): Don't check whether the
	target can async when running in the foreground.
	(step_1): Delete synchronous case handling.
	(step_once): Always install a continuation, even in sync mode.
	(until_next_command, finish_forward): Don't check whether the
	target can async.
	(attach_command_post_wait, notice_new_inferior): Always install a
	continuation, even in sync mode.
	* infrun.c (mark_infrun_async_event_handler): New function.
	(proceed): In sync mode, mark infrun's event source instead of
	waiting for events here.
	(fetch_inferior_event): If the target can't async, do a blocking
	wait.
	(prepare_to_wait): In sync mode, mark infrun's event source.
	(infrun_async_inferior_event_handler): No longer bail out if the
	target can't async.
	* infrun.h (mark_infrun_async_event_handler): New declaration.
	* linux-nat.c (linux_nat_wait_1): Remove calls to
	set_sigint_trap/clear_sigint_trap.
	(linux_nat_terminal_inferior): No longer check whether the target
	can async.
	* mi/mi-interp.c (mi_on_sync_execution_done): Update and simplify
	comment.
	(mi_execute_command_input_handler): No longer check whether the
	target is async.  Update and simplify comment.
	* target.c (default_target_wait): New function.
	* target.h (struct target_ops) <to_wait>: Now defaults to
	default_target_wait.
	(default_target_wait): Declare.
	* top.c (wait_sync_command_done): New function, factored out from
	...
	(maybe_wait_sync_command_done): ... this.
	* top.h (wait_sync_command_done): Declare.
	* target-delegates.c: Regenerate.
This commit is contained in:
Pedro Alves 2015-09-09 18:23:23 +01:00
parent ea4a7f9986
commit 0b333c5e7d
14 changed files with 173 additions and 198 deletions

View file

@ -3442,12 +3442,6 @@ linux_nat_wait_1 (struct target_ops *ops,
target_pid_to_str (lp->ptid));
}
if (!target_is_async_p ())
{
/* Causes SIGINT to be passed on to the attached process. */
set_sigint_trap ();
}
/* But if we don't find a pending event, we'll have to wait. Always
pull all events out of the kernel. We'll randomly select an
event LWP out of all that have events, to prevent starvation. */
@ -3518,9 +3512,6 @@ linux_nat_wait_1 (struct target_ops *ops,
ourstatus->kind = TARGET_WAITKIND_NO_RESUMED;
if (!target_is_async_p ())
clear_sigint_trap ();
restore_child_signals_mask (&prev_mask);
return minus_one_ptid;
}
@ -3546,9 +3537,6 @@ linux_nat_wait_1 (struct target_ops *ops,
sigsuspend (&suspend_mask);
}
if (!target_is_async_p ())
clear_sigint_trap ();
gdb_assert (lp);
status = lp->status;
@ -4629,17 +4617,6 @@ static int async_terminal_is_ours = 1;
static void
linux_nat_terminal_inferior (struct target_ops *self)
{
/* Like target_terminal_inferior, use target_can_async_p, not
target_is_async_p, since at this point the target is not async
yet. If it can async, then we know it will become async prior to
resume. */
if (!target_can_async_p ())
{
/* Async mode is disabled. */
child_terminal_inferior (self);
return;
}
child_terminal_inferior (self);
/* Calls to target_terminal_*() are meant to be idempotent. */