https://github.com/charles-zablit created 
https://github.com/llvm/llvm-project/pull/206029

`MAX_PATH` is defined as `260` on Windows. Unicode paths however can be up to 
32,767 characters long. 

Use `llvm::sys::windows:: widenPath` to convert paths to unicode paths to allow 
targets that have long path names.

This is the first part of a series of multiple commits that will fix long path 
support in lldb on Windows as well as adding regression tests.

>From a4a17d28a26fe35602ad4fbe6e24a059e0d709f9 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Fri, 26 Jun 2026 11:39:18 +0100
Subject: [PATCH] [lldb][windows] allow long paths in process launcher

---
 lldb/source/Host/windows/ProcessLauncherWindows.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 08750ebb95113..c0583f54bb316 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -15,6 +15,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/Windows/WindowsSupport.h"
 #include "llvm/Support/WindowsError.h"
 
 #include <string>
@@ -226,16 +227,20 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
   // command line is not empty, its contents may be modified by CreateProcessW.
   WCHAR *pwcommandLine = wcommandLine.empty() ? nullptr : &wcommandLine[0];
 
-  std::wstring wexecutable, wworkingDirectory;
-  llvm::ConvertUTF8toWide(launch_info.GetExecutableFile().GetPath(),
-                          wexecutable);
+  llvm::SmallVector<wchar_t, MAX_PATH> wexecutable;
+  if (std::error_code ec = llvm::sys::windows::widenPath(
+          launch_info.GetExecutableFile().GetPath(), wexecutable)) {
+    error = Status(ec);
+    return HostProcess();
+  }
+  std::wstring wworkingDirectory;
   llvm::ConvertUTF8toWide(launch_info.GetWorkingDirectory().GetPath(),
                           wworkingDirectory);
 
   PROCESS_INFORMATION pi = {};
 
   BOOL result = ::CreateProcessW(
-      wexecutable.c_str(), pwcommandLine, nullptr, nullptr,
+      wexecutable.data(), pwcommandLine, nullptr, nullptr,
       /*bInheritHandles=*/!inherited_handles.empty() ||
           pty_mode != PseudoConsole::Mode::None,
       flags, environment.data(),

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to