From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aLQCO1wyK2g2NyoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:30:04 -0400 Received: by simark.ca (Postfix, from userid 112) id EE70F1E11C; Mon, 19 May 2025 09:30:04 -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 E74981E102 for ; Mon, 19 May 2025 09:30:03 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7FD0F385841D for ; Mon, 19 May 2025 13:30:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FD0F385841D Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by sourceware.org (Postfix) with ESMTPS id 7FE123858C31 for ; Mon, 19 May 2025 13:23:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FE123858C31 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 7FE123858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661032; cv=none; b=qSpDb/hkkVVcV4PUe1wT43evwEd1fh98MECm/bnQRFhf7LKjcmYMjEUZR1cnyxqal1ZIj1/hNkIBFJNdU4VMNZkJMjNL5UrcrdfiSfSpzly79EX7JYzy1vyQivt4JmKqBPs6wn6ieScTHxS3pvXrrF1ffjiZm8nlMGEZis94IWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661032; c=relaxed/simple; bh=HRk/rAus/u9fuGXPJ6b96xgie22XbC31dpcP9b9YFlE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Q0lIaf3i2ZUBvFgqj94EfQyMmpYHGpmYzafOmCSBcERlAgcI0K1ntHY8KkSitXRdJ9eKLpYhNzLE0nRPCW6UPtYjpoJpfgcD1OdY7eL9WoWpJGcjAoU6GBuYra3nyWpPcvVle8iq/aTnrI70KPyvXWJ/JvdVl3FR3NDjEaV1qhg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FE123858C31 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-43cfba466b2so47797175e9.3 for ; Mon, 19 May 2025 06:23:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661031; x=1748265831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iqiMdy05MemoIdNWbk0ikoystdY3PDhHRf94D2gUaB8=; b=r3poot8xTbpsJTLoreiha6Ldu4Qy6y45bwa0d4bHwAXjU9F9MtCGOrX8DnTAYntn+S US4SaS2i3TJdX989CfcoDkgfn2A0oJkEZhsDqJVaqoIyPZHWbdLnx6GuC9Y9vq9kBMz3 668u5F2sUlq9KezjluGdCuVg10YY5sQ5s1Yq8L+oaF7mh70YrEz1jwSaB/DyB6dC3XOP IK13ZuewoAKl8sW7TOzEMqGBbw13GEspyZH39saQTzxIOKncDgEKwce2RXGuEsPCkv4K OZVd0xlnBMPPb+NCw3btTzsPjtUTRc/cnYOaplM+Nr6Ly7728kedYmqAJwLN2L9mV6l8 11nA== X-Gm-Message-State: AOJu0YxGWY5yrHbjky2CyHdhkFcSi2pl+TncyoQOkp6UhIpWfmr/BTfB n7ZeeFrNuq6kaSzercGFec42ze0PqDX7NR76A/zW1xVTJhTzJm/W2JS+YIJtC08Y X-Gm-Gg: ASbGncvGEsnicen6SHxMxYk4/bR8DXm6stHbFL2bR1JkuxvuJ9+m+2mF6JzC7p+ji/w HCGK93PXRQBzezly/dENWk04sa5+FRmDwIAf9R4XYCryVfiknc28DzKSKvr/RnGfwRS1BpAO1yX mSdD7CuyV3C239IjO5hR96yNuhSSWSbV8fLJLe2aWqwWcC4VnvLCNfCcPvDRmXnFVWloyQvVtz+ ibe/x6hZJ7U/HCTts3/VX7bcDQFUz6FUYVoh067aCG5U9BGXKO5vGx835RmliDkVbHs8VNC1QB2 U1XpmkIKstFEzezvTyS4SEqKtibrmbWLebukVN51idv/sbp2x7c= X-Google-Smtp-Source: AGHT+IGdpbM23ZJojy+sFKkbuX9tsqelwSO4vt+3HUMExoLtBhsSizOwhObk1YH4ZHpckXX9YnsLfw== X-Received: by 2002:a05:600c:3c82:b0:43d:1b74:e89a with SMTP id 5b1f17b1804b1-445229b4341mr49218195e9.9.1747661031012; Mon, 19 May 2025 06:23:51 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442fd4fdcccsm145601315e9.6.2025.05.19.06.23.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:23:50 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 12/47] Windows gdb+gdbserver: Eliminate DONT_SUSPEND Date: Mon, 19 May 2025 14:22:33 +0100 Message-ID: <20250519132308.3553663-13-pedro@palves.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519132308.3553663-1-pedro@palves.net> References: <20250519132308.3553663-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 There's a single call to thread_rec(DONT_SUSPEND), in windows_process_info::handle_exception. In GDB, the windows-nat.c thread_rec implementation avoids actually calling SuspendThread on the event thread by doing: th->suspended = -1; I am not exactly sure why, but it kind of looks like it is done as an optimization, avoiding a SuspendThread call? It is probably done for the same reason as the code touched in the previous patch avoided suspending the event thread. This however gets in the way of non-stop mode, which will really want to SuspendThread the event thread for DBG_REPLY_LATER. In gdbserver's thread_rec implementation DONT_SUSPEND is ignored, and thread_rec actually always suspends, which really suggests that SuspendThread on the event thread is really not a problem. I really can't imagine why it would be. DONT_SUSPEND invalidates the thread's context, but there is no need to invalidate the context when we get an event for a thread, because we invalidate it when we previously resumed the thread. So, we can just remove the thread_rec call from windows_process_info::handle_exception. That's what this patch does. Approved-By: Tom Tromey Change-Id: I0f328542bda6d8268814ca1ee4ae7a478098ecf2 --- gdb/nat/windows-nat.c | 4 ---- gdb/nat/windows-nat.h | 2 -- gdb/windows-nat.c | 11 ----------- 3 files changed, 17 deletions(-) diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index b68d99a2496..40a58a0afd9 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -356,10 +356,6 @@ windows_process_info::handle_exception (struct target_waitstatus *ourstatus, memcpy (&siginfo_er, rec, sizeof siginfo_er); - /* Record the context of the current thread. */ - thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0), - DONT_SUSPEND); - last_sig = GDB_SIGNAL_0; switch (code) diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index f7f2f3e62a7..4fb38e81631 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -107,8 +107,6 @@ struct windows_thread_info /* Possible values to pass to 'thread_rec'. */ enum thread_disposition_type { - /* Invalidate the context, but do not suspend the thread. */ - DONT_SUSPEND, }; /* A single pending stop. See "pending_stops" for more diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index be62d2a6cad..2425ec5f897 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -536,17 +536,6 @@ windows_per_inferior::thread_rec (ptid_t ptid, thread_disposition_type disposition) { windows_thread_info *th = find_thread (ptid); - - if (th != nullptr && !th->suspended) - { - switch (disposition) - { - case DONT_SUSPEND: - th->suspended = -1; - invalidate_context (th); - break; - } - } return th; } -- 2.49.0