diff options
author | Pedro Alves <palves@redhat.com> | 2015-09-09 18:23:23 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-09-09 18:23:23 +0100 |
commit | 0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25 (patch) | |
tree | 3adaca984618d51de1b6dd44a48b83417b01f919 /gdb/infcall.c | |
parent | ea4a7f9986ed4614d8ffb85ccd4fa4bb49b6d420 (diff) | |
download | gdb-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/infcall.c')
-rw-r--r-- | gdb/infcall.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/gdb/infcall.c b/gdb/infcall.c index ad5f004..734d6b5 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -36,6 +36,8 @@ #include "gdbthread.h" #include "event-top.h" #include "observer.h" +#include "top.h" +#include "interps.h" /* If we can't find a function's name from its address, we print this instead. */ @@ -388,10 +390,13 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) ptid_t call_thread_ptid = call_thread->ptid; int saved_sync_execution = sync_execution; int was_running = call_thread->state == THREAD_RUNNING; + int saved_interpreter_async = interpreter_async; /* Infcalls run synchronously, in the foreground. */ - if (target_can_async_p ()) - sync_execution = 1; + sync_execution = 1; + /* So that we don't print the prompt prematurely in + fetch_inferior_event. */ + interpreter_async = 0; call_thread->control.in_infcall = 1; @@ -404,25 +409,11 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) TRY { - int was_sync = sync_execution; - proceed (real_pc, GDB_SIGNAL_0); /* Inferior function calls are always synchronous, even if the - target supports asynchronous execution. Do here what - `proceed' itself does in sync mode. */ - if (target_can_async_p ()) - { - wait_for_inferior (); - normal_stop (); - /* If GDB was previously in sync execution mode, then ensure - that it remains so. normal_stop calls - async_enable_stdin, so reset it again here. In other - cases, stdin will be re-enabled by - inferior_event_handler, when an exception is thrown. */ - if (was_sync) - async_disable_stdin (); - } + target supports asynchronous execution. */ + wait_sync_command_done (); } CATCH (e, RETURN_MASK_ALL) { @@ -430,6 +421,13 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) } END_CATCH + /* If GDB was previously in sync execution mode, then ensure that it + remains so. normal_stop calls async_enable_stdin, so reset it + again here. In other cases, stdin will be re-enabled by + inferior_event_handler, when an exception is thrown. */ + sync_execution = saved_sync_execution; + interpreter_async = saved_interpreter_async; + /* At this point the current thread may have changed. Refresh CALL_THREAD as it could be invalid if its thread has exited. */ call_thread = find_thread_ptid (call_thread_ptid); @@ -470,8 +468,6 @@ run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) if (call_thread != NULL) call_thread->control.in_infcall = saved_in_infcall; - sync_execution = saved_sync_execution; - return caught_error; } |