[Lldb-commits] [lldb] [lldb][Windows] Add SVE register read/write support in lldb-server (PR #205906)

Omair Javaid via lldb-commits lldb-commits at lists.llvm.org
Sun Aug 16 15:38:06 PDT 2026


================
@@ -58,6 +69,39 @@ def _is_supported_darwin(self, cmd_runner):
 
         return None, (output.strip() == "1")
 
+    # PowerShell may not be on PATH on minimal Windows images, and Add-Type
+    # requires the .NET CLR and the CSC compiler to be available. Neither is
+    # guaranteed.
+    # TODO: Replace the PowerShell chain with a probe that calls
+    # 'IsProcessorFeaturePresent' directly.
+    def _is_supported_windows(self, cmd_runner):
+        import base64
+
+        if self.windows_processor_feature is None:
+            return f"Unspecified processor feature ID for {self}", False
+
+        # IsProcessorFeaturePresent() via PowerShell
+        ps_script = (
+            "Add-Type -TypeDefinition '"
+            "using System; using System.Runtime.InteropServices; "
+            "public class WinAPI { "
+            '[DllImport("kernel32.dll")] '
+            "public static extern bool IsProcessorFeaturePresent(uint f); }'; "
+            f"[WinAPI]::IsProcessorFeaturePresent({self.windows_processor_feature})"
+        )
+
+        # PowerShell -EncodedCommand expects UTF-16LE Base64.
+        encoded = base64.b64encode(ps_script.encode("utf-16-le")).decode("ascii")
+        cmd = f"powershell -EncodedCommand {encoded}"
+        err, retcode, output = cmd_runner(cmd)
+        if err.Fail() or retcode != 0:
+            return (
+                "Windows SVE detection via PowerShell failed "
+                "(retcode={0}, output={1!r})".format(retcode, output)
+            ), False
+
+        return None, (output.strip().lower() == "true")
+
----------------
omjavaid wrote:

Few questions and comments about above changes:
1. Is there a simpler Windows command line alternative to PowerShell for querying CPU features? Something like`reg query` that does not need .NET runtime at all might be worth exploring first.

2. Does this probe gets invoked every time `isSupported()` is called? That could be many times during a testsuite run in future. Can we cache the result ?

3. Have you considered writing a query in dotest.py itself for the lifetime of the testsuite something like: https://github.com/llvm/llvm-project/blob/89e98de49b198f8c8f94d87a75ee38fbd4223f38/lldb/packages/Python/lldbsuite/test/dotest.py#L873

`canRunLibcxxTests()` runs on host but I think your SVE probe can be run on remote as well. Regardless you have to compile it on the host side.
 
4. Some concerns on the PowerShell path - `Add-Type` invokes CSC compiler under the hood so how long does this actually take on a slow CI machine. 
Also which verision of windows dont have PS on path? Does GH action runners expose PS on path? 

5. How we tell that SVE was present but PS failed?

https://github.com/llvm/llvm-project/pull/205906


More information about the lldb-commits mailing list