From: Andrew Burgess Date: Mon, 22 Nov 2021 12:30:36 +0000 (+0000) Subject: gdb: add assert in remote_target::wait relating to async being off X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d34471f70a84e6db89be40116d1ed0f6af941c0;p=binutils-gdb.git gdb: add assert in remote_target::wait relating to async being off While working on another patch I ended up in a situation where I had async mode disabled (with 'maint set target-async off'), but the async event token got marked anyway. In this situation GDB was continually calling into remote_target::wait, however, the async token would never become unmarked as the unmarking is guarded by target_is_async_p. We could just unconditionally unmark the token, but that would feel like just ignoring a bug, so, instead, lets assert that if !target_is_async_p, then the async token should not be marked. This assertion would have caught my earlier mistake. There should be no user visible changes with this commit. --- diff --git a/gdb/remote.c b/gdb/remote.c index f0f3dcbabb0..1bb6138a7c7 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8348,9 +8348,13 @@ remote_target::wait (ptid_t ptid, struct target_waitstatus *status, remote_state *rs = get_remote_state (); /* Start by clearing the flag that asks for our wait method to be called, - we'll mark it again at the end if needed. */ + we'll mark it again at the end if needed. If the target is not in + async mode then the async token should not be marked. */ if (target_is_async_p ()) clear_async_event_handler (rs->remote_async_inferior_event_token); + else + gdb_assert (!async_event_handler_marked + (rs->remote_async_inferior_event_token)); ptid_t event_ptid;