[Lldb-commits] [lldb] [lldb][windows] allow longer paths than MAX_PATH in GetFileNameByLoadAddress (PR #200225)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Thu May 28 10:09:25 PDT 2026


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

DLLs can be longer than MAX_PATH. This is causing test failures when running `check-lldb` in a Windows Docker container. 

This patch allow long paths when calling `GetFileNameByLoadAddress`.

https://github.com/llvm/llvm-project/pull/198795#discussion_r3276277895 was correct.

>From f0bce07aec8f1681548745a7dee4963a7d146899 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 28 May 2026 18:06:45 +0100
Subject: [PATCH] [lldb][windows] allow longer paths than MAX_PATH in
 GetFileNameByLoadAddress

---
 .../Plugins/Process/Windows/Common/DebuggerThread.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
index c4bfa11e9635d..660bd7bd75498 100644
--- a/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
@@ -555,11 +555,14 @@ static std::optional<std::string> GetFileNameByLoadAddress(HANDLE hProcess,
   }
 
   // Fallback: ask the kernel for the file backing the mapping at this address.
-  std::array<wchar_t, MAX_PATH + 1> mapped_filename;
-  if (!::GetMappedFileNameW(hProcess, base_addr, mapped_filename.data(),
-                            mapped_filename.size()))
+  std::vector<wchar_t> mapped_filename(PATHCCH_MAX_CCH);
+  DWORD mapped_len = ::GetMappedFileNameW(
+      hProcess, base_addr, mapped_filename.data(), mapped_filename.size());
+  if (!mapped_len)
     return std::nullopt;
-  return ConvertNtDevicePathToDosPath(mapped_filename);
+  std::optional<std::string> dos_path = ConvertNtDevicePathToDosPath(
+      llvm::ArrayRef<wchar_t>(mapped_filename.data(), mapped_len + 1));
+  return dos_path;
 }
 
 // Resolve the LOAD_DLL_DEBUG_INFO::lpImageName field.



More information about the lldb-commits mailing list