summaryrefslogtreecommitdiff
path: root/gdb/mi
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/mi
parentea4a7f9986ed4614d8ffb85ccd4fa4bb49b6d420 (diff)
downloadbinutils-gdb-0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25.tar.gz
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/mi')
-rw-r--r--gdb/mi/mi-interp.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 99ce385169c..0935c8f8d91 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -309,16 +309,8 @@ mi_execute_command_wrapper (const char *cmd)
static void
mi_on_sync_execution_done (void)
{
- /* MI generally prints a prompt after a command, indicating it's
- ready for further input. However, due to an historical wart, if
- MI async, and a (CLI) synchronous command was issued, then we
- will print the prompt right after printing "^running", even if we
- cannot actually accept any input until the target stops. See
- mi_on_resume. However, if the target is async but MI is sync,
- then we need to output the MI prompt now, to replicate gdb's
- behavior when neither the target nor MI are async. (Note this
- observer is only called by the asynchronous target event handling
- code.) */
+ /* If MI is sync, then output the MI prompt now, indicating we're
+ ready for further input. */
if (!mi_async_p ())
{
fputs_unfiltered ("(gdb) \n", raw_stdout);
@@ -333,20 +325,12 @@ mi_execute_command_input_handler (char *cmd)
{
mi_execute_command_wrapper (cmd);
- /* MI generally prints a prompt after a command, indicating it's
- ready for further input. However, due to an historical wart, if
- MI is async, and a synchronous command was issued, then we will
- print the prompt right after printing "^running", even if we
- cannot actually accept any input until the target stops. See
- mi_on_resume.
-
- If MI is not async, then we print the prompt when the command
- finishes. If the target is sync, that means output the prompt
- now, as in that case executing a command doesn't return until the
- command is done. However, if the target is async, we go back to
- the event loop and output the prompt in the
- 'synchronous_command_done' observer. */
- if (!target_is_async_p () || !sync_execution)
+ /* Print a prompt, indicating we're ready for further input, unless
+ we just started a synchronous command. In that case, we're about
+ to go back to the event loop and will output the prompt in the
+ 'synchronous_command_done' observer when the target next
+ stops. */
+ if (!sync_execution)
{
fputs_unfiltered ("(gdb) \n", raw_stdout);
gdb_flush (raw_stdout);