From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CUFsCfUwK2ioNSoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:24:05 -0400 Received: by simark.ca (Postfix, from userid 112) id 140C81E11C; Mon, 19 May 2025 09:24:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 D8D191E102 for ; Mon, 19 May 2025 09:24:03 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6771C3858289 for ; Mon, 19 May 2025 13:24:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6771C3858289 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id AA11E385841F for ; Mon, 19 May 2025 13:23:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA11E385841F 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 AA11E385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747660993; cv=none; b=at1fqODKnvu4sXeMI1gpBdFbSKUHXRNRjhUkWMQYDocdKwqk4h/UGvJ4mMpSzKQy1JbefHfgj+IK117HWs5GibDNAyLDA61XNUnkAxPCF2F+P0FpO25rxACEXrN69X21zwpnUV/JiUG+mibXVkxh9AEch8jAQv6XrFu2YokbnPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747660993; c=relaxed/simple; bh=AgqCWznny8GxXIpSSqy6e8qcnmS+yCxAbmkZoGXLrVQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Lqs0Hx3j4+du9o4PHNqcIY9YGqqZtHGWhJ6v6X9jLece01pdeB6IvORtxJ5+Tz8V03sDgXGST48+zWhHfd2RVpWVYkTqSxVGrk9PUg9bddUgCa4T0c6TWRbzZqfx8fppoGk4qT9qgX/eiKaUTXsLWIqnkmg+R8uK9bXl6xxTvBc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA11E385841F Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a35c894313so2578710f8f.2 for ; Mon, 19 May 2025 06:23:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747660992; x=1748265792; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZreLYr83W1F68JX+ocMeGp8bAgbb0QtUdsgXXx325G8=; b=g/kO87KpG92j/eNnwgGr/UZwcukS6VoeGkIr05bOXPHjt4vraD0+c12lR5ZnnP+gvJ Ps1NlR4akDVB2XJPNhv5bYBdF/t9Rhb1ByvmzoY2MCPGoT8AMfdE8Jrmml/2JMSKIB+D NIa8CdIzMjoZmbufqkWh2mbzALSwLmBKTR4+m7MCFl570qhejKnvHAfISc5VsbDZQiYi fD6t4ijjaVOXwcm80hLyOPXlWnJRJeSA4BmwFtJC2fDmAvOK/wQCpVyKBfMnwSiRvprj W0FOtaiRX9JAQFk6rZTRG+UJyMa31lhFRIIi6bXLBq3YHWD+PKW1dDkE/Vlsuy6EyXWa fFkg== X-Gm-Message-State: AOJu0Yz334JWL0LTBPiYxWHmPHXr4b2XRVZmaRoFx7156IHXYekvqXVs 7J9i2+2w8dWc9H3H9QwcwEthNsT/nl85DMHyw/sqF7s0fJy3aQiV4z59OFVCssZs X-Gm-Gg: ASbGncvLbbwZfQ9h0x4++mc4+MiC+s6kZB3agaRxGxyG7NfuS95GNsrhj54xxHKmBY1 L4ymiX+f7Fq6kK+bDN3bxVHTocJH6dp64MJJ5+QQvGSrxEjytOhWzdqhrJ6XhyDwrgwgkto0TcM awP5ExX4R6FrK8iYF2bzP5/D/YzOTs/qeiwSp1QPVh+KSvyHo3pr7hXB+Z0HpnuZvq9WiAzTve1 9cmIX5+/qNL2F5V2qdt0Pleo2mb/xy90/BBGyms83HbvDkdyMok+RDNbPCsF5R22WTKEyzOsck0 /e2Be/0u5s8xi8yKYNBF9mX9G7MifjcJ6sDV7vKXWSv8lbS8xAM= X-Google-Smtp-Source: AGHT+IHMGFtnox27eMt5y8tTyl9G6KIXWc3clZBfoYBXAkrPysGY7Cw9rFuVcm+VDYnYtXpjKJVNCA== X-Received: by 2002:a05:6000:2211:b0:3a3:6e62:d8e5 with SMTP id ffacd0b85a97d-3a36e62db78mr3382355f8f.53.1747660992046; Mon, 19 May 2025 06:23:12 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a35ca4d258sm12779045f8f.20.2025.05.19.06.23.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:23:11 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 00/47] Windows non-stop mode Date: Mon, 19 May 2025 14:22:21 +0100 Message-ID: <20250519132308.3553663-1-pedro@palves.net> X-Mailer: git-send-email 2.49.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 After a long while (a year, w00t!), here is another iteration of the Windows non-stop work. I've pushed the series to the users/palves/windows-non-stop-v2 branch on sourceware.org, for your convenience. Compared to the previous version from a year ago (gasp!), here: https://inbox.sourceware.org/gdb-patches/20240507234233.371123-1-pedro@palves.net/ ... many issues where fixed, and it should be a lot more stable. I think I fixed the problems Tromey found out when he ran the series against the AdaCore testsuite, particularly around detaching. The series is bigger, it is now 47 patches instead of 34. These patches are new: + [PATCH v2 01/47] Make default_gdb_exit resilient to failed closes + [PATCH v2 02/47] Add test for continuing with some threads running + [PATCH v2 03/47] infrun: Remove unnecessary currently_stepping call + [PATCH v2 04/47] infrun: Split currently_stepping, fix sw watchpoints issue + [PATCH v2 05/47] thread_info::executing+resumed -> thread_info::internal_state + [PATCH v2 36/47] linux-nat: Factor out get_detach_signal code to common code + [PATCH v2 37/47] Windows GDB: make windows_thread_info be private thread_info data + [PATCH v2 38/47] Introduce windows_nat::event_code_to_string + [PATCH v2 40/47] Windows gdb: Eliminate invalidate_context + [PATCH v2 42/47] gdb_test_multiple: Anchor prompt match if -lbl + [PATCH v2 43/47] Windows gdb: extra thread info => show exiting + [PATCH v2 44/47] Add gdb.threads/leader-exit-schedlock.exp + [PATCH v2 45/47] infrun: with AS+NS, prefer process exit over thread exit + [PATCH v2 46/47] Windows gdb: Always non-stop The last one above (#46) was split from the main non-stop patch so that AS-on-NS is only activated after the new infrun changes are merged. Note that patches above with subject that starts with "infrun" or "thread_info" are changes to common code. This patch from the previous version of the series was dropped: - windows_per_inferior::continue_one_thread, unify WoW64/non-WoW64 paths ... as no longer needed, since Hannes's: commit b2682eade4db993bc8231007ba94aec4e4728c61 Author: Hannes Domani AuthorDate: Fri Dec 6 14:04:00 2024 +0100 Reduce WOW64 code duplication The "Windows gdb: Add non-stop support" patch changed in some important areas compared to the previous version. Here's a summary: - We can't use DBG_REPLY_LATER with thread/process exit events. For those, we need to use the pre-exiting pending-status mechanism. - When a thread that is abruptly killed has a pending DBG_REPLY_LATER reply queued in the kernel, we always see that queued event first before the thread exit event. - The above two points required careful handling of the (th->suspended == -1) state in some places. - windows-nat.c was in some cases deleting the thread before reporting TARGET_WAITKIND_THREAD_EXITED to infrun (when target_thread_events was active), resulting in a double free, because infrun deletes the thread as well. OTOH, when TARGET_WAITKIND_THREAD_EXITED was reported and windows-nat.c didn't delete the thread, nothing was deleting the corresponding windows_thread_info object, resulting weird confusion in the windows backend, with stale threads still in the backend list. - TARGET_WAITKIND_NO_RESUMED is now implemented. - The new "Add gdb.threads/leader-exit-schedlock.exp" patch adds a test that exercises all the points above. The pre-existing "gdb.base/ending-run.exp" testcase also covers some aspects. - Adjusted to new model introduced by the "thread_info::executing+resumed -> thread_info::internal_state" patch earlier in the series. - Adjusted to windows_thread_info being owned by the thread_info object. - The do_initial_windows_stuff run-to-initial-breakpoint loop now handles target_thread_events enabled correctly. - Fixes detaching with queued DBG_REPLY_LATER events on the kernel side. The Windows kernel re-raises any exception previously intercepted and deferred with DBG_REPLY_LATER in the inferior after we detach. We need to flush those events, otherwise the inferior dies immediately after the detach, due to an unhandled exception. - The intro text added to windows-nat.c has more paragraphs and sections detailing the new things I've learned along the way since the last time. In the NEWS patch, I'm now mentioning scheduler-locking support too. Previously I only mentioned non-stop. I've added "Approved-By:" tags from last year's review, to patches that haven't changed since. Some of them I could have pushed back then, but I didn't want to do that until the v2 series was complete, in case some problems I was addressing in v2 were caused by those preparatory patches. The "prerequisite-patch-id" at the bottom is: [PATCH] Fix build when RUSAGE_THREAD is not available & add warning https://inbox.sourceware.org/gdb-patches/20250517213056.3251858-1-pedro@palves.net/T/#u Here's the original intro blurb, still accurate: This series adds non-stop mode support to the Windows native backend, on Windows 10 and above. Earlier Windows versions lack the necessary feature, so those keep working in all-stop mode, only. After the series, the Windows target backend defaults to working in non-stop mode (as in, "maint set target-non-stop"), even if user-visible mode is all-stop ("set non-stop off"). This is the same as the Linux backend. I've been testing this on Cygwin native with the GDB testsuite as I've been developing this. Running the testsuite on Cygwin is a pain, and many testcases run into cascading timeouts still, and some even hang the test run forever until you kill them manually. I've got another series of patches to improve such tests and skip others, and that's what I've been testing with. I've also tested the series with the windows-nat backend forced to all-stop mode. Pedro Alves (47): Make default_gdb_exit resilient to failed closes Add test for continuing with some threads running infrun: Remove unnecessary currently_stepping call infrun: Split currently_stepping, fix sw watchpoints issue thread_info::executing+resumed -> thread_info::internal_state Windows gdb: Dead code in windows_nat_target::do_initial_windows_stuff Windows gdb: Eliminate global current_process.dr[8] global Windows gdb+gdbserver: New find_thread, replaces thread_rec(DONT_INVALIDATE_CONTEXT) Windows gdb: handle_output_debug_string return type Windows gdb: Eliminate reload_context Windows gdb+gdbserver: Eliminate thread_rec(INVALIDATE_CONTEXT) calls Windows gdb+gdbserver: Eliminate DONT_SUSPEND Windows gdb+gdbserver: Eliminate windows_process_info::thread_rec Windows gdb: Simplify windows_nat_target::wait Windows gdb+gdbserver: Move suspending thread to when returning event Windows gdb: Introduce continue_last_debug_event_main_thread Windows gdb: Introduce windows_continue_flags Windows gdb: Factor code out of windows_nat_target::windows_continue Windows gdb: Pending stop and current_event Windows gdb+gdbserver: Elim desired_stop_thread_id / rework pending_stops Windows gdb+gdbserver: Introduce get_last_debug_event_ptid Windows gdb: Can't pass signal to thread other than last stopped thread Windows gdbserver: Fix scheduler-locking Windows gdb: Enable "set scheduler-locking on" Windows gdbserver: Eliminate soft-interrupt mechanism Windows gdb+gdbserver: Make current_event per-thread state Windows gdb+gdbserver: Make last_sig per-thread state Windows gdb+gdbserver: Make siginfo_er per-thread state Add backpointer from windows_thread_info to windows_process_info Windows gdb+gdbserver: Share $_siginfo reading code Windows gdb+gdbserver: Eliminate struct pending_stop Windows gdb: Change serial_event management Windows gdb: cygwin_set_dr => windows_set_dr, etc. Windows gdb: Avoid writing debug registers if watchpoint hit pending Windows gdb+gdbserver: Check whether DBG_REPLY_LATER is available linux-nat: Factor out get_detach_signal code to common code Windows GDB: make windows_thread_info be private thread_info data Introduce windows_nat::event_code_to_string Windows gdb: Add non-stop support Windows gdb: Eliminate invalidate_context Windows gdb: Watchpoints while running (internal vs external stops) gdb_test_multiple: Anchor prompt match if -lbl Windows gdb: extra thread info => show exiting Add gdb.threads/leader-exit-schedlock.exp infrun: with AS+NS, prefer process exit over thread exit Windows gdb: Always non-stop (default to "maint set target-non-stop on") Mention Windows scheduler-locking and non-stop support in NEWS gdb/NEWS | 6 + gdb/aarch64-tdep.c | 2 +- gdb/amd-dbgapi-target.c | 8 +- gdb/breakpoint.c | 9 +- gdb/bsd-uthread.c | 4 +- gdb/fork-child.c | 4 +- gdb/frame.c | 4 +- gdb/gcore.c | 4 +- gdb/gdbthread.h | 150 +- gdb/i386-tdep.c | 4 +- gdb/inf-ptrace.c | 2 +- gdb/infcall.c | 8 +- gdb/infcmd.c | 39 +- gdb/inferior.h | 4 +- gdb/inflow.c | 2 +- gdb/infrun.c | 429 ++-- gdb/infrun.h | 13 +- gdb/linux-fork.c | 9 +- gdb/linux-nat.c | 44 +- gdb/linux-thread-db.c | 4 +- gdb/mi/mi-cmd-var.c | 4 +- gdb/mi/mi-interp.c | 2 +- gdb/mi/mi-main.c | 8 +- gdb/nat/windows-nat.c | 176 +- gdb/nat/windows-nat.h | 223 +- gdb/process-stratum-target.c | 6 +- gdb/python/py-infthread.c | 6 +- gdb/record-btrace.c | 20 +- gdb/record-full.c | 6 +- gdb/regcache.c | 2 +- gdb/remote.c | 76 +- gdb/sol-thread.c | 4 +- gdb/target.c | 15 +- .../gdb.threads/continue-some-running.c | 76 + .../gdb.threads/continue-some-running.exp | 52 + .../gdb.threads/leader-exit-schedlock.c | 56 + .../gdb.threads/leader-exit-schedlock.exp | 215 ++ .../gdb.threads/step-over-process-exit.c | 49 + .../gdb.threads/step-over-process-exit.exp | 66 + .../sw-watchpoint-step-over-bp-with-threads.c | 64 + ...w-watchpoint-step-over-bp-with-threads.exp | 91 + gdb/testsuite/lib/gdb.exp | 8 +- gdb/thread-iter.h | 2 +- gdb/thread.c | 299 ++- gdb/top.c | 2 +- gdb/windows-nat.c | 2033 +++++++++++++---- gdbserver/win32-low.cc | 450 ++-- gdbserver/win32-low.h | 19 +- 48 files changed, 3369 insertions(+), 1410 deletions(-) create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.c create mode 100644 gdb/testsuite/gdb.threads/continue-some-running.exp create mode 100644 gdb/testsuite/gdb.threads/leader-exit-schedlock.c create mode 100644 gdb/testsuite/gdb.threads/leader-exit-schedlock.exp create mode 100644 gdb/testsuite/gdb.threads/step-over-process-exit.c create mode 100644 gdb/testsuite/gdb.threads/step-over-process-exit.exp create mode 100644 gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.c create mode 100644 gdb/testsuite/gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp base-commit: e1ec485cfa29f9c45370b9d0c12480ebb0a0be06 prerequisite-patch-id: 474281ed1de7dcad710a9f1415fe4866fe3e36cb -- 2.49.0