From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KPbZEcczK2hiOCoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:36:07 -0400 Received: by simark.ca (Postfix, from userid 112) id 46FF91E11C; Mon, 19 May 2025 09:36:07 -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 C6BC51E102 for ; Mon, 19 May 2025 09:36:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17CCF3858401 for ; Mon, 19 May 2025 13:36:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17CCF3858401 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by sourceware.org (Postfix) with ESMTPS id CAB433857C5D for ; Mon, 19 May 2025 13:25:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAB433857C5D 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 CAB433857C5D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661102; cv=none; b=tOB0a4WaWsIBvVO3h41YRjrwVa4RPSEJwZG5M0TgrzclvskHT8odkP7dmyMFPqcabTFVhbT8xCe8+KVw4TTiE9z1qlZQTxBRT1pLMraF0xMN0zsbYBZ/ZvpgrnkLn9G5RIjYn+toJIrXwxnnxJGlM+1e0actUMR9IVFFNuP4B/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661102; c=relaxed/simple; bh=pxSpfCtU2iKtoyAgepWxRpQ+/zTRsM853aMvT5C7JJM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=XDUORoMVN4mADh/1c+rgZGqx35cDyN/Qh5WBQjdz/3rsxaHynXX0RXUoBsHAYdnBdk1W8muE8hSGnUBGOJ2cYFbXCdWSvF5otwyRvbWjPzsjKuwmh7L7aQtKJ4M+DQJNxqLSO0Dx/kgT9QrwIwBoHbFYfQOU28ZsRcuGLmYoxs0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAB433857C5D Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-43cec5cd73bso29375665e9.3 for ; Mon, 19 May 2025 06:25:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661100; x=1748265900; 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=JTo5CvVbQ0+d0Q2EjOn7qMBCZo4tdZ3MlveHaeNgnG8=; b=CbQY/+C5SsJpKB9gLej7hwQZVWGtKWtX2s0zx4t+hwElzCbli4xS0vSmC5VcpysHWp 4ZGAwcP0wqLK1dZ9JdaOu4SJ1X3I2cPYz19PbOJ3VC2MDZXKE7OqnbY6ehiR2x6pOJGR PQnsem3XK9JjY3cUCU1/22PdFtnnRHmNgbkynuOVb+cUr2ghTHtnsKWZu4uGbUS/7ywV ly9fCUhgwuTFD8Gv/EY5rPtaxVJSsgqOYdcY4IOKQQepY0/H/50tLNq7peYL+2SM/PU3 JUsP1VH5s+7Y6jZCM6RlIWjJ9xmNe7UK0nrNIerwo0/BIEDZtToo5osv4QTYcRpi8Ljg IZiw== X-Gm-Message-State: AOJu0YzRHLwAVMzRKs+XEZxgoCZ29HvucdSrs2q8j2MeMWoE4/l7gg0/ ZMfECTWhoxQdO2K62nGoPU2+z5b0UF+L3gpdtx66hEf5e0E75ogLT1cXOtvFoaGG X-Gm-Gg: ASbGncsA06ObzGmfB+U7BvmWMwn1j1laDkcsNEPwMFGCNjU2m/5KJhhVPMtQBXZj3CG p/5jmqHVN3IAfBFpBVfv5sFfreGTquiuG2+d4IkQy0YjPMIXi5+9j8RwIcwJ0RmFJsOl7Cb5NQu 0nFTWX5GQwbFtU/ZFUhfYLq/al2TSz22QlsxQhGMhQf5PoD586r976IFrdN+1tKXemDd32ZjrgD JG9jpP0Z/kErUMa3R0Ik/t5yHFblMoO2dN5yNk5jTXJkLd2wCYpx5vZbNS92kXKEGC+X3b7i8YM vr1eQ8MpT7Z3cBHJSm9y6BUNLApBUuG7z/Atzq8/iTCn+8bxtG0= X-Google-Smtp-Source: AGHT+IEmOjC74wbfScnXnPmrj/cI5K2FChlXhwZTWploq7h134ZSh/fzRzTVV8IWtqu5FEeq7YLVHw== X-Received: by 2002:a05:600c:4e42:b0:43c:e70d:4504 with SMTP id 5b1f17b1804b1-442fd64dfccmr121520115e9.19.1747661100218; Mon, 19 May 2025 06:25:00 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442eb85a8f8sm125556605e9.0.2025.05.19.06.24.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:24:59 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Hannes Domani , Eli Zaretskii , Tom Tromey Subject: [PATCH v2 35/47] Windows gdb+gdbserver: Check whether DBG_REPLY_LATER is available Date: Mon, 19 May 2025 14:22:56 +0100 Message-ID: <20250519132308.3553663-36-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 Per , DBG_REPLY_LATER is "Supported in Windows 10, version 1507 or above, ..." Since we support versions of Windows older than 10, we need to know whether DBG_REPLY_LATER is available. And we need to know this before starting any inferior. This adds a function that probes for support (and caches the result), by trying to call ContinueDebugEvent on pid=0,tid=0 with DBG_REPLY_LATER, and inspecting the resulting error. Suggested-by: Hannes Domani Suggested-by: Eli Zaretskii Approved-By: Tom Tromey Change-Id: Ia27b981aeecaeef430ec90cebc5b3abdce00449d --- gdb/nat/windows-nat.c | 20 ++++++++++++++++++++ gdb/nat/windows-nat.h | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c index a548acc97d3..907d39f317a 100644 --- a/gdb/nat/windows-nat.c +++ b/gdb/nat/windows-nat.c @@ -912,6 +912,26 @@ disable_randomization_available () /* See windows-nat.h. */ +bool +dbg_reply_later_available () +{ + static int available = -1; + if (available == -1) + { + /* DBG_REPLY_LATER is supported since Windows 10, Version 1507. + If supported, this fails with ERROR_INVALID_HANDLE (tested on + Win10 and Win11). If not supported, it fails with + ERROR_INVALID_PARAMETER (tested on Win7). */ + if (ContinueDebugEvent (0, 0, DBG_REPLY_LATER)) + internal_error (_("ContinueDebugEvent call should not " + "have succeeded")); + available = (GetLastError () != ERROR_INVALID_PARAMETER); + } + return available; +} + +/* See windows-nat.h. */ + bool initialize_loadable () { diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h index 795d6c485fe..667fc832292 100644 --- a/gdb/nat/windows-nat.h +++ b/gdb/nat/windows-nat.h @@ -532,6 +532,15 @@ enum_process_modules (WOW64_CONTEXT *, HANDLE process, } #endif +/* This is available starting with Windows 10. */ +#ifndef DBG_REPLY_LATER +# define DBG_REPLY_LATER 0x40010001L +#endif + +/* Return true if it's possible to use DBG_REPLY_LATER with + ContinueDebugEvent on this host. */ +extern bool dbg_reply_later_available (); + /* Load any functions which may not be available in ancient versions of Windows. */ -- 2.49.0