[03/11] gdb, remote: fix async handler assertion on reconnect to non-stop target

Message ID 20260518183316.127043-4-mohamed.bouhaouel@intel.com
State New
Headers
Series Enable non-stop mode by default for remote targets |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Bouhaouel, Mohamed May 18, 2026, 6:32 p.m. UTC
  From: "Bouhaouel, Mohamed" <mohamed.bouhaouel@intel.com>

When reconnecting to a non-stop remote target during
process_initial_stop_replies (), the code attempts to mark an async event
handler before async mode is enabled.  This causes an assertion failure
in remote_state::mark_async_event_handler (), which requires the serial
connection to be in async mode (is_async_p () == true).

Fix by changing the condition in queued_stop_reply () from
target_can_async_p () to target_is_async_p (), matching the pattern used
in push_stop_reply ().  When async mode is later enabled, the event
handler will be marked then.

Scenario:
    - Connect to non-stop remote target.
    - Thread receives signal (e.g., SIGUSR1) and stops.
    - Disconnect and reconnect.
    - Assertion fails because mark_async_event_handler () requires
      is_async_p ().
---
 gdb/remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 4bdbf4aeb08..b7ccd72829b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8385,7 +8385,7 @@  remote_target::queued_stop_reply (ptid_t ptid)
   remote_state *rs = get_remote_state ();
   stop_reply_up r = remote_notif_remove_queued_reply (ptid);
 
-  if (!rs->stop_reply_queue.empty () && target_can_async_p ())
+  if (!rs->stop_reply_queue.empty () && target_is_async_p ())
     {
       /* There's still at least an event left.  */
       rs->mark_async_event_handler ();