[Lldb-commits] [lldb] [lldb][windows] add support for out of PATH python.dll resolution (PR #162509)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 8 15:41:59 PDT 2025


================
@@ -426,6 +433,47 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
   return error;
 }
 
+#ifdef _WIN32
+// Returns the full path to the lldb.exe executable
+inline std::wstring GetPathToExecutableW() {
+  // Iterate until we reach the Windows max path length (32,767).
+  std::vector<WCHAR> buffer;
+  buffer.resize(MAX_PATH);
+  while (buffer.size() < 32767) {
+    if (GetModuleFileNameW(NULL, buffer.data(), buffer.size()) < buffer.size())
+      return std::wstring(buffer.begin(), buffer.end());
+    buffer.resize(buffer.size() * 2);
+  }
+  return L"";
+}
+
+// Resolve the full path of the directory defined by
+// LLDB_PYTHON_DLL_RELATIVE_PATH. If it exists, add it to the list of DLL search
+// directories.
+void AddPythonDLLToSearchPath() {
+  std::wstring modulePath = GetPathToExecutableW();
+  if (modulePath.empty()) {
+    WithColor::error() << "Unable to find python: " << GetLastError() << '\n';
----------------
adrian-prantl wrote:

We typically with the word "error:" in the error color, and not the entire message.

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


More information about the lldb-commits mailing list