From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 98EE43858C62 for ; Sun, 12 May 2024 03:44:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98EE43858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 98EE43858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715485443; cv=none; b=hVMqqkufI/hstBIafzlYs8HMFdFvaOG1vlA2D7v9zQz04wI2+oSxagfgnzEMUbbB9pJGajLtP0FT9/GnXnqPV3QCPhkpVCS7fpj7zX8qL72sC4H2nsMys/ZuLbQyQvfR/CClhAbqS2DaV1Vy3Rlj1aQ+Me/FYrOO6Y9euxWF4uY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715485443; c=relaxed/simple; bh=mo9jSqGBGIg+YCaBIe35yv4NTv8f8vCOkVsohzLfMi8=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=BXj6sb1MQJJERIl5sZu3toDtLJXMldGHSqBTDEo4jtysgF4xPc2QY7bB8/HHvdiuVnjgiytm0VIEEpBaXvsnosyCwKSi6tpiq1xswbL06HmJJjoW3auYt3yo+wFGg82ZVZhkKHOz0X4/vyYIT9IN1SWWENh5jz8usXgJ/0J6U1Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4gfa-00083M-Cl; Wed, 08 May 2024 08:45:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=OOhZzOpscSSp24a0kOnkFCVnhM0cyE/O2cff4Yc//J0=; b=fmc2OuvOVS/A h7+1ztmIEYGI7VkGVT0oX7Rq5e0YcEBNw/TANfylxAHWw33AbxnmcMJTeNURQP6ggeRfU3KwleBJY OYj3fAGuAFkkmc+O0tgrGTTB0KtDeMBw3HXrACtqwdDexFVRpbaeSvyprBBOS74y3DKbKCh9nAQjv MFRr4kPrWpfPCE2ahjlb4eHaeBdxdDF0MPurjoCU5dqMsKkA1hQq/BLU3S1UYN3qbq1lu8V2i0CJM 7XykcDPfyI9OXb+unMrL38xAGZiaH23AzSLA9ccRwJUYJbUiX5tDNPa9LlDM1B6SbP32ke7hiadOo VRfeWE5WABFoN6pEW4HfSg==; Date: Wed, 08 May 2024 15:45:01 +0300 Message-Id: <86edaca2wi.fsf@gnu.org> From: Eli Zaretskii To: Pedro Alves Cc: gdb-patches@sourceware.org In-Reply-To: <20240507234233.371123-32-pedro@palves.net> (message from Pedro Alves on Wed, 8 May 2024 00:42:30 +0100) Subject: Re: [PATCH 31/34] Windows gdb+gdbserver: Check whether DBG_REPLY_LATER is available References: <20240507234233.371123-1-pedro@palves.net> <20240507234233.371123-32-pedro@palves.net> X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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: > From: Pedro Alves > Date: Wed, 8 May 2024 00:42:30 +0100 > > Windows has a number of functions you can use to check the OS version, > like GetVersion/GetVersionEx, or the Version Helper functions like > IsWindows10OrGreater, VerifyVersionInfo, etc., however, as explained by > > https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa > > ... and other pages, "Applications not manifested for Windows 8.1 or > Windows 10 will return the Windows 8 OS version value (6.2)." > > "Manifested" here means that the application is linked with an xml > manifest as detailed at: > https://learn.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1 > > I have actually tried doing that with windres, but I wasn't able to > make it work. It should be easy to do that by providing a separate manifest file as part of the tarball, and installing it alongside gdb.exe as part of "make install". Emacs does that, for example, and thus can make use of the accurate Windows version where it needs that using GetVersion/GetVersionEx. On Windows 11, for example, I get this in Emacs: M-: (w32-version) RET => (10 0 22631) However, ... > However, I found out that we can find the Windows major/minor/build in > the KUSER_SHARED_DATA structure, which defines the layout of a data > area that the kernel places at a pre-set address for sharing with > user-mode software: > > https://www.geoffchappell.com/studies/windows/km/ntoskrnl/structs/kuser_shared_data/index.htm > > The Windows major/minor/build version retrieved using that method > bypasses the manifest stuff, it actually gets you the real OS version > numbers. That is what this patch is using. ...do we really need to do this via a version-check? Can't we instead just call ContinueDebugEvent and if it fails, consider DBG_REPLY_LATER unsupported? (If calling ContinueDebugEvent with that flag on older versions of Windows causes an exception, we could use try/catch.) If this works, it is a more reliable way to test, IMO and IME. I think we should prefer that to poking kernel data structures. WDYT?