[Lldb-commits] [lldb] [lldb-dap][windows] allow STDIN to be a console (PR #178409)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 29 03:03:45 PST 2026


================
@@ -0,0 +1,62 @@
+# REQUIRES: python, system-windows
+# RUN: %python %s %lldb-dap > %t.out 2>&1
+# RUN: FileCheck %s --check-prefix=ERROR < %t.out
+
+# ERROR-NOT: DAP session error:
+
+# Test that we can successfully start the dap server from the console on Windows.
+
+import sys
+import subprocess
+import os
+
+lldb_dap_path = sys.argv[1]
+if lldb_dap_path.startswith('%'):
+    lldb_dap_path = lldb_dap_path[1:]
+lldb_dap_path = os.path.normpath(lldb_dap_path)
+
+import ctypes
+from ctypes import wintypes
+import msvcrt
+
+GENERIC_READ = 0x80000000
+GENERIC_WRITE = 0x40000000
+OPEN_EXISTING = 3
+FILE_SHARE_READ = 0x00000001
+FILE_SHARE_WRITE = 0x00000002
+
+kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
+
+conin_handle = kernel32.CreateFileW(
+    "CONIN$",
----------------
charles-zablit wrote:

> Just checking my understanding, I believe this opens the current processes console input handle, then on line 48, we forward it to the subprocess.

Yes, the reason is that when running `lldp-dap` without this in a shell test, the console would be a `PIPE` device, meaning we were not testing the code path. This is the only trick I could find to make stdin be a `CHAR` device.

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


More information about the lldb-commits mailing list