From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qYYNI+TW62kyVDkAWB0awg (envelope-from ) for ; Fri, 24 Apr 2026 16:47:32 -0400 Received: by simark.ca (Postfix, from userid 112) id 8216E1E0CA; Fri, 24 Apr 2026 16:47:32 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 E29A31E093 for ; Fri, 24 Apr 2026 16:47:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E851B4BAE7ED for ; Fri, 24 Apr 2026 20:47:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E851B4BAE7ED Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by sourceware.org (Postfix) with ESMTPS id 3E2CC4B92092 for ; Fri, 24 Apr 2026 20:46:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3E2CC4B92092 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 3E2CC4B92092 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063569; cv=none; b=LV4Supbzc3Wu0UgQR1YjMcUL+osLUVYU6OwVNfil5pMHtS65lJ1vGVLmtolPVoVl/ifOvsNbIHVP/VOQ0YJIbW48t1mH2LdmMj9XE5CO2N8/RqqacnK25Ka0zw6KvAnAOYVkWEu+O2I7dPIqKanlpDQZYfqvHtYoueQJKZldY6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777063569; c=relaxed/simple; bh=egSkdXzPV9/C8M80dLEFchffT2C4zUqB3mufA6Ic85E=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=olOFGw07WK1wCs/ic96YEQPwqjs6omCpzTtvKd5a4rSIv3TgssyyXrgrMj3icnXuw7TR3r/nMY1OUG8GQ3O30HHI6n6cAbGpZpRKuWQQqCXH//SKrXqubMgb+k2d1hkdnTBT7I79nDqE+LRH+qWC9DWLZXahm31xIb+dnY/WEKU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E2CC4B92092 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso66481445e9.0 for ; Fri, 24 Apr 2026 13:46:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777063568; x=1777668368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=m/V00zocEhgX2lgOTADrgmbSUhjL6hVmBokV/H0tqvc=; b=tA6ryPOk80Ent4h7ddNy0rQbQvrnQTm0d1Evs2rPHmjfE7VnnHtZMrZ9SWysMtqizj EHy8upoJNF4HSDXHm6cL8GT9AkDGYvGiP1mtWNOYaY4QdqwU1lzMqlXnOi1E4Mn7KIQa PPzSRfZ4sDNu+XalFbqsLErbxWG2DzsiQ62PRayas9HggsfaB2l8ry92fJhQn3JanzJt FS9RZr1NEVzFFWZt6bxCC34ssCpujxNGg3/l466utHMX29UhD5jZgBWQkCuqVvhGzFFx 0135dXR6+cbcG9nKXjptJ1sYCBethd4w9af9lY4hhUoQMQRJoNqdzmlkP+Em4nnep4PJ bLfw== X-Gm-Message-State: AOJu0YwVFNIyt10C1dwHKN3IKlSgyIi1RFGa4gU7YhaqAp+EoASpcI/d BxCV1Es2vlEqqWrASgzAh1vndlGjcDzbYZ3hho6VNlUGnUFMydtynGr6uYxzEWqq X-Gm-Gg: AeBDieuyjwR6vwWPe0treyO5e4sGzyc0PGIqZ7vDUKI43L8iPc/ZAjoGbp+YgyxzLyu RrPPX33RtG76mhIml+2rVf+rN3Ll3XCQUB4mXxLlg63Hl3J19TzsE3UY3RHZEqu47SJcwVPLjB0 jodTeTVptpg+N3Jfstu592heqbV/6ZyeWmE7lFLbG5hW66xNf4Q3+8I+gsAINxL8DD84izEauJ2 tTXlJrViJkPjrv5S26aEvewzABZSiOQjgeexM2RaG7MkqdoheVVDiB4OyoKJxWub9hEOPh9njdV TfB9DTwm9QhZiizodUqoRqz7v+62btr5voII87d6VcteeADFjvi6oLrPyuYM2KwSklNLb4raPmZ 6E24o8PxD2Ba4FcuolDOOjtZYY7xGxMWQ/qYcmIGmKYj53PW2fQog7VvvJrwfxpnC+2p+3KgPUp rAoyYEdDTwk3r4AAwk8EJW5MPKDF90sLTF X-Received: by 2002:a05:600c:3150:b0:480:3ad0:93bf with SMTP id 5b1f17b1804b1-488fb7930famr480765965e9.24.1777063567772; Fri, 24 Apr 2026 13:46:07 -0700 (PDT) Received: from localhost ([2001:8a0:facb:a800:7315:8865:c664:fc06]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-4891c08faffsm724470895e9.1.2026.04.24.13.46.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Apr 2026 13:46:07 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed 18/28] Windows gdbserver: Eliminate soft-interrupt mechanism Date: Fri, 24 Apr 2026 21:44:58 +0100 Message-ID: <20260424204508.1343973-19-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424204508.1343973-1-pedro@palves.net> References: <20260424204508.1343973-1-pedro@palves.net> 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 I noticed that faked_breakpoint is write only. And then I hacked win32_process_target::request_interrupt to force it to stop threads using the soft_interrupt_requested mechanism (which suspends threads, and then fakes a breakpoint event in the main thread), and saw that it no longer works -- gdbserver crashes accessing a NULL current_thread, because fake_breakpoint_event does not switch to a thread. This code was originally added for Windows CE, as neither GenerateConsoleCtrlEvent nor DebugBreakProcess worked there. Windows CE support has since been removed. We nowadays require Windows XP or later, and XP has DebugBreakProcess. The soft_interrupt_requested mechanism has other problems, like for example faking the event in the main thread, even if that thread was previously stopped, due to scheduler-locking. A following patch will add a similar mechanism stopping all threads with SuspendThread to native GDB, for non-stop mode, which doesn't have these problems. It's different enough from this old code that I think we should just rip the old code out, and reimplement it from scratch (based on gdb's version) when we need it. Approved-By: Tom Tromey Change-Id: I89e98233a9c40c6dcba7c8e1dacee08603843fb1 --- gdbserver/win32-low.cc | 39 +-------------------------------------- gdbserver/win32-low.h | 8 -------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index be01940d158..5caec960082 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -289,8 +289,6 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached) windows_process.process_id = pid; windows_process.main_thread_id = 0; - windows_process.soft_interrupt_requested = 0; - windows_process.faked_breakpoint = 0; windows_process.open_process_used = true; memset (&windows_process.current_event, 0, @@ -407,7 +405,6 @@ child_continue_for_kill (DWORD continue_status, int thread_id) { continue_one_thread (thread, thread_id); }); - windows_process.faked_breakpoint = 0; return continue_last_debug_event (continue_status, debug_threads); } @@ -907,30 +904,6 @@ suspend_one_thread (thread_info *thread) th->suspend (); } -static void -fake_breakpoint_event (void) -{ - OUTMSG2(("fake_breakpoint_event\n")); - - windows_process.faked_breakpoint = 1; - - memset (&windows_process.current_event, 0, - sizeof (windows_process.current_event)); - windows_process.current_event.dwThreadId = windows_process.main_thread_id; - windows_process.current_event.dwDebugEventCode = EXCEPTION_DEBUG_EVENT; - windows_process.current_event.u.Exception.ExceptionRecord.ExceptionCode - = EXCEPTION_BREAKPOINT; - - /* On aarch64, hardware breakpoints also get EXCEPTION_BREAKPOINT, - but they can be recognized with ExceptionInformation. */ - windows_process.current_event.u.Exception.ExceptionRecord.NumberParameters - = 1; - windows_process.current_event.u.Exception.ExceptionRecord - .ExceptionInformation[0] = 0; - - for_each_thread (suspend_one_thread); -} - /* See nat/windows-nat.h. */ bool @@ -983,13 +956,6 @@ get_child_debug_event (DWORD *continue_status, DEBUG_EVENT *current_event = &windows_process.current_event; - if (windows_process.soft_interrupt_requested) - { - windows_process.soft_interrupt_requested = 0; - fake_breakpoint_event (); - goto gotevent; - } - windows_process.attaching = 0; { process_info *proc = find_process_pid (windows_process.process_id); @@ -1030,8 +996,6 @@ get_child_debug_event (DWORD *continue_status, } } - gotevent: - switch (current_event->dwDebugEventCode) { case CREATE_THREAD_DEBUG_EVENT: @@ -1285,8 +1249,7 @@ win32_process_target::request_interrupt () if (DebugBreakProcess (windows_process.handle)) return; - /* Last resort, suspend all threads manually. */ - windows_process.soft_interrupt_requested = 1; + OUTMSG2 (("Could not interrupt.\n")); } bool diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index 402254fdad5..9c672bfce1a 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -191,14 +191,6 @@ struct gdbserver_windows_process : public windows_nat::windows_process_info debug event off the win32 API. */ struct target_waitstatus cached_status; - /* Non zero if an interrupt request is to be satisfied by suspending - all threads. */ - int soft_interrupt_requested = 0; - - /* Non zero if the inferior is stopped in a simulated breakpoint done - by suspending all the threads. */ - int faked_breakpoint = 0; - /* True if current_process_handle needs to be closed. */ bool open_process_used = false; -- 2.53.0