From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id C88E73858D37 for ; Tue, 7 May 2024 23:43:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C88E73858D37 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 C88E73858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125384; cv=none; b=CVuvCTkM2dXFXggGfgRoYJyHhgCVGzg/wz7QH6hk2JWAnPmMPLEh+Buzmn7SOmvcNE1PiH2n3YeDZuryCoDuomWZyGJtZj8I0omwnSbAfvlwUOjb3W9er0BGByRYQWDvR0fzDeUiwyIfIAR1TzHh9byzpNQtRvr8GSfp0BTKZPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125384; c=relaxed/simple; bh=ubZ6tclCf2ifuaxUof5yjOCgf9tYzJ2I6cE0kcG8xAU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=gzmBER7VCADkbLA/53o95pIJVtEgrxMBGQUgn6mM9vCBmh6IcABeo7+Byy3e883gqnjQZ7WR6AIXLmBa26CPH3CESBwaUlzi52ZT35h+6EAYRraRUjuaOfL8E6tbnsVXMGzCUhn01QWQONVYC9fszjEarkj8r5Y05eT2lG6GnLY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-34d7a32bdd3so1941300f8f.0 for ; Tue, 07 May 2024 16:43:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715125380; x=1715730180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eiAA9mYMuyJl+EPA7tP+xqUoBHIwRuXZ5NR36did0Vs=; b=nY9o2O3S5E/Zj9S0kuujbdCQvmuQTQHSf00lf+0VWV07NliVxu5zUg9JXeeJMJAXGk mUK68NfGXGhH33lYebRQl41DFHVPdpcCE3ecdeh1Eo6g+buc165vPXHXPhl3nqJXk3tB /OAgEBpDAT159c/14oEQKT0aMN+GMBVWtQRXxW8+gpQ7lcA4rAKvxMD0aKJTvFSh0FI5 SlvUKbt4Ec8W7S7UB3KFojGCHeDkpfn9sEZ1jH+r1ZmDJc9S1GpgY3UBsVEb8J39TS6p rlL8Hd9sZbIp3JVV/d8L1QWzujVkG27qh2b5sap5dY2t0i8D1hu6srHNgjnDhejM2WEj sI+g== X-Gm-Message-State: AOJu0YxgK98NWV+9TyfCJdKsHnIe4Uhpl8RA0n8Jy7YTJuqJ77r/GFUP 7G9nRKRavH81GIWbdzcIR2Bj6UbOWjQxMFm3Ncf4/miA0EQvE5nmfqlH5oCQ X-Google-Smtp-Source: AGHT+IElgDECbG4JyB1meTdBhn80ubCTihS/NIJeZkHLzSoVlhBapzM9O2J3ISM8YWI0UlAdvlnjrQ== X-Received: by 2002:a5d:4210:0:b0:34c:ceee:b311 with SMTP id ffacd0b85a97d-34fca243c28mr695381f8f.28.1715125380418; Tue, 07 May 2024 16:43:00 -0700 (PDT) Received: from localhost ([2001:8a0:f908:4900:2dd1:1a0d:2b75:dc42]) by smtp.gmail.com with UTF8SMTPSA id d3-20020a5d6443000000b0034da4e80885sm13869585wrw.59.2024.05.07.16.42.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 16:43:00 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 07/34] Windows gdb+gdbserver: Eliminate DONT_SUSPEND Date: Wed, 8 May 2024 00:42:06 +0100 Message-ID: <20240507234233.371123-8-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240507234233.371123-1-pedro@palves.net> References: <20240507234233.371123-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. 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 46fbc2bfecb..b5cfad6274b 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -366,10 +366,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 0e2093ee06d..e18edc995b5 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -101,8 +101,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 f53a45f657f..f5435d70ed3 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -542,17 +542,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.43.2