From 635b2dd919b8c58e164b77c396041935fca1d66a Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 3 Oct 2023 22:04:01 -0400 Subject: gdb: add assertion when marking the remote async flag As reported in bug 30630 [1], we hit a case where the remote target's async flag is marked while the target is not configured (yet) to work async. This should not happen. It is caught thanks to this assert in remote_target::wait: /* Start by clearing the flag that asks for our wait method to be called, 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 ()) rs->clear_async_event_handler (); else gdb_assert (!rs->async_event_handler_marked ()); This is helpful, but I think that we could have caught the problem earlier than that, at the moment we marked the handler. Catching problems earlier makes them easier to debug. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=30630 Change-Id: I7e229c74b04da82bef6a817d5a676be5cf52e833 Approved-By: Andrew Burgess --- gdb/remote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gdb/remote.c') diff --git a/gdb/remote.c b/gdb/remote.c index 5f12f93..961061e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -425,7 +425,10 @@ public: } void mark_async_event_handler () - { ::mark_async_event_handler (m_async_event_handler_token); } + { + gdb_assert (this->is_async_p ()); + ::mark_async_event_handler (m_async_event_handler_token); + } void clear_async_event_handler () { ::clear_async_event_handler (m_async_event_handler_token); } -- cgit v1.1