From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id J8EaKSN2NWrtlg8AWB0awg (envelope-from ) for ; Fri, 19 Jun 2026 13:02:27 -0400 Received: by simark.ca (Postfix, from userid 112) id 941111E098; Fri, 19 Jun 2026 13:02:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C39141E070 for ; Fri, 19 Jun 2026 13:02:26 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7930A4BAE7D5 for ; Fri, 19 Jun 2026 17:02:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7930A4BAE7D5 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id 3F2A24BAE7CB for ; Fri, 19 Jun 2026 17:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F2A24BAE7CB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3F2A24BAE7CB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781888521; cv=none; b=s1ikpXzqrg1s1eICUpUvb4HGY9K4a11ydKw9Ndg591k4BLtV5dAgB8pXEzkzQBPBWxJAZuggATpnO82RA/qiLobaWMZxaF7PACmWqWUabysYvtANvMew2xXdnwIOH/TbDEpuB0vpfLfn5aqIy9sik4vywqKNO7Y4QgTVLEsS1DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781888521; c=relaxed/simple; bh=QkuVr1IAP51iCGtFNCWKCdFw0frNuGhTylKVTDsOlSU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=tN/NTT5Aq47eGtiCJ3AJouENL1XDBN7IIIR9V9lvLoe0GRdVmKaCo3u/uHtdp7w/Cy+UdEkOY7xZxgTfhiLCUEu6kfHB2HMzJG0TCx6MmVFnBrt84W4YqrbXcmpmHDW6R9ExipbXu9EJNJBWmVVXN/iY8W7npVVFzWkEZ8HGE+s= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F2A24BAE7CB Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-46255b269c2so1792183f8f.3 for ; Fri, 19 Jun 2026 10:02:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781888520; x=1782493320; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4eVLvF6exfF/wlbp+IJEny91f4mACBCbd+JEgh2XvqY=; b=SOUyfj35c/QIVkAy96a4xh0YhMhuOvhdcY18HEHWHrRcyfEZuSjbIrbP9lNaC5GmmR Tqxo9hfuayDmEIhn00EADTJ0YgjdliUbVgDrcv8OMFIk+a3ZHRIHM9TFEk2nRogGSEGd wrF9pjCHQA6ObHIvkn9cCua/WN+oybE5LsOHsJrdy+AO0VLiLpfD5En5ZQcEM2RwfjHK aXMpCnphQYSdIUd1SJMUaA8OzUWlriat8AgYUU63E+wf2AJi9IVyzInZ3n66vZ8aly78 PvCQG+Ru48V7JQvz0bpMULnzwmOC+H1yP04kup2hjzOl3lTO69pHhunFTJvogdFtSJKz jszg== X-Gm-Message-State: AOJu0YxumZVdbUUCh9BhE7u1056BhPhyyse1uKY7LyVExGzNMaLsglLE mzHcqYqtzYaBJZrh+2R1mUK1OBxmIpe9DccXligEFdslE767KNj3PzRuZm4HyA== X-Gm-Gg: AfdE7cns5Z6amKsyugmfx8BdX6xVbkbEykqYQ32AK5SQe4D/veeNXjIxlu4b5y2PhOG B5k1eiC3kfXh3ENv8Vdad5/v1U5jkjZhpG+O2gTchus/T7n5WgQY3xe1iErCA4JvvgXQjoF822W xki+wgaD8KgMntXN0xy8X+v7EI7ZzaGr+UP0sSHm207JExxcfpr0YQesJhoXcpARc0l4VTnC9GN 3Y4+ncdWzf+gsl9ahnw44Cqnvuyv7K6BxN2Yv+9YgHpnAHEX1OK+ey2RX5cCUYMj024DQEB3dn7 Vg1WFYMHMgVUirm9E45vespzT9ujnEnVXwx84u5IcgM7qQn2uGoGUKMEnbeRBS9boW8tIv1DG37 5/be/H44nlNdyB5U4b1lzjlFi9vrLftK7ovfn1dTDiSK4ea//oJzWY0PgbcliaUF/ZFdDT7dlW+ pdeIIfSVSflMnTC9k5dJwnRA== X-Received: by 2002:a7b:c384:0:b0:490:b642:ce31 with SMTP id 5b1f17b1804b1-4923ef53bcemr60365565e9.2.1781888519753; Fri, 19 Jun 2026 10:01:59 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:2600:fa79:b88e:8dae:a26f]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4923ff821aasm83189565e9.12.2026.06.19.10.01.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Jun 2026 10:01:59 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Fix amd_dbgapi_target::wait's handling of TARGET_WAITKIND_IGNORE Date: Fri, 19 Jun 2026 18:01:51 +0100 Message-ID: <20260619170151.821207-1-pedro@palves.net> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Windows, a ROCgdb downstream testcase (gdb.rocm/register-watchpoint.exp, which we can't upstream yet due to missing support for DWARF 6 features upstream) currently fails with a timeout, like so: (gdb) PASS: gdb.rocm/register-watchpoint.exp: continue to breakpoint: bit_extract_kernel watch $s32 Watchpoint 3: $s32 (gdb) PASS: gdb.rocm/register-watchpoint.exp: watchpoint on a stack pointer of the first wave continue Continuing. FAIL: gdb.rocm/register-watchpoint.exp: continue (timeout) Running the test manualy with some extra logging, we see: [infrun] stop_all_threads: 6/7 waits_needed << extra [amd-dbgapi] wait: ptid = -1.0.0 [windows events] get_windows_debug_event: kernel event for pid=7036 tid=0x4e8 code=EXCEPTION_DEBUG_EVENT [windows events] get_windows_debug_event: get_windows_debug_event - unexpected stop in suspended thread 0x4e8 [windows events] continue_last_debug_event: ContinueDebugEvent (cpid=7036, ctid=0x4e8, DBG_REPLY_LATER) [windows events] wait: get_windows_debug_event returned [0.0.0 : status->kind = IGNORE, fake=0] [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) = [infrun] print_target_wait_results: 0.0.0 [process 0], [infrun] print_target_wait_results: status->kind = IGNORE [infrun] print_target_wait_results: from target 1 (native) [infrun] wait_one: about to block in interruptible_select << extra So we're in stop_all_threads, and we've pulled the stop events for all CPU threads already, but then we hang in interruptible_select waiting for the last stop event, which happens to be for the GPU wave. In wait_one, before the interruptible_select call, we poll events from the target, via target_wait with WNOHANG, and so we get here: ptid_t amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws, target_wait_flags target_options) { ... ptid_t event_ptid = beneath ()->wait (ptid, ws, target_options); if (event_ptid != minus_one_ptid) { ... return event_ptid; } ... handle dbgapi events ... So above, we call the beneath target's wait. On Windows that may hit that "get_windows_debug_event - unexpected stop in suspended thread 0x4e8" path, which makes windows_nat_target::wait return TARGET_WAITKIND_IGNORE. The Windows target pairs that with event_ptid == ptid_t(0,0,0) though, so the 'if then' branch is taken and we return the TARGET_WAITKIND_IGNORE to the core without looking for dbgapi events. The event for the wave stop at this point has already been flushed from the dbgapi library into amd-dbgapi-target's dbgapi local event queue, and so wait_one ends up deadlocked in interruptible_select, which results in the timeouts observed. Nothing specifies that TARGET_WAITKIND_IGNORE must be returned with minus_one_ptid. infrun never looks at the event ptid if the status is TARGET_WAITKIND_IGNORE. So fix this by tweaking amd_dbgapi_target::wait to not assume that either. Change-Id: I6cbbeebdc8146e361ead72829b59f82531c90fc7 --- gdb/amd-dbgapi-target.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c index 610a484becd..d0424044e0c 100644 --- a/gdb/amd-dbgapi-target.c +++ b/gdb/amd-dbgapi-target.c @@ -1690,7 +1690,8 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws, amd_dbgapi_debug_printf ("ptid = %s", ptid.to_string ().c_str ()); ptid_t event_ptid = beneath ()->wait (ptid, ws, target_options); - if (event_ptid != minus_one_ptid) + if (ws->kind () != TARGET_WAITKIND_NO_RESUMED + && ws->kind () != TARGET_WAITKIND_IGNORE) { if (ws->kind () == TARGET_WAITKIND_EXITED || ws->kind () == TARGET_WAITKIND_SIGNALLED) @@ -1703,9 +1704,6 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws, return event_ptid; } - gdb_assert (ws->kind () == TARGET_WAITKIND_NO_RESUMED - || ws->kind () == TARGET_WAITKIND_IGNORE); - /* Flush the async handler first. */ if (target_is_async_p ()) async_event_handler_clear (); base-commit: fd3cf86c638b7fdc0ccb64e178ec43ccd7e9d3f9 -- 2.54.0