diff --git a/gdb/infcmd.c b/gdb/infcmd.c index fc27904..8fb133c 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2821,6 +2821,15 @@ attach_command (char *args, int from_tty) mark_infrun_async_event_handler (); return; } + else + { + /* We don't expect any additional attach event from the target. + So make sure that the infrun_async_event_handler is disabled. + Otherwise, the main event loop might believe that we have + inferior events ready, causing us to wait for those event + that will never come, since our inferior is now stopped. */ + infrun_async (0); + } /* Done with ARGS. */ do_cleanups (args_chain); diff --git a/gdb/infrun.c b/gdb/infrun.c index cf91370..2c189f9 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -107,29 +107,20 @@ static int maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc); when we have pending events ready to be passed to the core. */ static struct async_event_handler *infrun_async_inferior_event_token; -/* Stores whether infrun_async was previously enabled or disabled. - Starts off as -1, indicating "never enabled/disabled". */ -static int infrun_is_async = -1; - /* See infrun.h. */ void infrun_async (int enable) { - if (infrun_is_async != enable) - { - infrun_is_async = enable; - - if (debug_infrun) - fprintf_unfiltered (gdb_stdlog, - "infrun: infrun_async(%d)\n", - enable); + if (debug_infrun) + fprintf_unfiltered (gdb_stdlog, + "infrun: infrun_async(%d)\n", + enable); - if (enable) - mark_async_event_handler (infrun_async_inferior_event_token); - else - clear_async_event_handler (infrun_async_inferior_event_token); - } + if (enable) + mark_async_event_handler (infrun_async_inferior_event_token); + else + clear_async_event_handler (infrun_async_inferior_event_token); } /* See infrun.h. */