aboutsummaryrefslogtreecommitdiff
path: root/gdb/infrun.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-09-09 18:23:23 +0100
committerPedro Alves <palves@redhat.com>2015-09-09 18:23:23 +0100
commit0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25 (patch)
tree3adaca984618d51de1b6dd44a48b83417b01f919 /gdb/infrun.c
parentea4a7f9986ed4614d8ffb85ccd4fa4bb49b6d420 (diff)
downloadgdb-0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25.zip
gdb-0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25.tar.gz
gdb-0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25.tar.bz2
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.
Diffstat (limited to 'gdb/infrun.c')
-rw-r--r--gdb/infrun.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 70dffca..273c2bc 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -131,6 +131,14 @@ infrun_async (int enable)
}
}
+/* See infrun.h. */
+
+void
+mark_infrun_async_event_handler (void)
+{
+ mark_async_event_handler (infrun_async_inferior_event_token);
+}
+
/* When set, stop the 'step' command if we enter a function which has
no line number information. The normal behavior is that we step
over such function. */
@@ -3094,15 +3102,11 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
discard_cleanups (old_chain);
- /* Wait for it to stop (if not standalone)
- and in any case decode why it stopped, and act accordingly. */
- /* Do this only if we are not using the event loop, or if the target
- does not support asynchronous execution. */
+ /* Tell the event loop to wait for it to stop. If the target
+ supports asynchronous execution, it'll do this from within
+ target_resume. */
if (!target_can_async_p ())
- {
- wait_for_inferior ();
- normal_stop ();
- }
+ mark_async_event_handler (infrun_async_inferior_event_token);
}
@@ -3766,7 +3770,8 @@ fetch_inferior_event (void *client_data)
make_cleanup_restore_integer (&execution_direction);
execution_direction = target_execution_direction ();
- ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws, TARGET_WNOHANG);
+ ecs->ptid = do_target_wait (waiton_ptid, &ecs->ws,
+ target_can_async_p () ? TARGET_WNOHANG : 0);
if (debug_infrun)
print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
@@ -7520,10 +7525,10 @@ prepare_to_wait (struct execution_control_state *ecs)
if (debug_infrun)
fprintf_unfiltered (gdb_stdlog, "infrun: prepare_to_wait\n");
- /* This is the old end of the while loop. Let everybody know we
- want to wait for the inferior some more and get called again
- soon. */
ecs->wait_some_more = 1;
+
+ if (!target_is_async_p ())
+ mark_infrun_async_event_handler ();
}
/* We are done with the step range of a step/next/si/ni command.
@@ -8816,14 +8821,6 @@ static const struct internalvar_funcs siginfo_funcs =
static void
infrun_async_inferior_event_handler (gdb_client_data data)
{
- /* If the target is closed while this event source is marked, we
- will reach here without execution, or a target to call
- target_wait on, which is an error. Instead of tracking whether
- the target has been popped already, or whether we do have threads
- with pending statutes, simply ignore the event. */
- if (!target_is_async_p ())
- return;
-
inferior_event_handler (INF_REG_EVENT, NULL);
}