[Lldb-commits] [lldb] [windows] improve python3.dll load check (PR #168864)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 24 03:55:14 PST 2025
================
@@ -477,18 +477,17 @@ bool AddPythonDLLToSearchPath() {
#endif
#ifdef LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME
-/// Returns whether `python3x.dll` is in the DLL search path.
+/// Returns true if `python3x.dll` can be loaded.
bool IsPythonDLLInPath() {
#define WIDEN2(x) L##x
#define WIDEN(x) WIDEN2(x)
- WCHAR foundPath[MAX_PATH];
- DWORD result =
- SearchPathW(nullptr, WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME), nullptr,
- MAX_PATH, foundPath, nullptr);
+ HMODULE h = LoadLibraryW(WIDEN(LLDB_PYTHON_RUNTIME_LIBRARY_FILENAME));
----------------
charles-zablit wrote:
I agree that this is a bit more expensive, I tried to benchmark it:
# Before the change
```powershell
Measure-Command { for($i=1; $i -le 50; $i++){.\bin\lldb.exe -o exit --batch }}
TotalSeconds : 10.643811
TotalMilliseconds : 10643.811
```
# After the change
```powershell
Measure-Command { for($i=1; $i -le 50; $i++){.\bin\lldb.exe -o exit --batch }}
TotalSeconds : 10.680583
TotalMilliseconds : 10680.583
```
That's a `0.34%` increase, I think that's reasonable considering the benefits we get form properly letting the user know `python.dll` is not available.
https://github.com/llvm/llvm-project/pull/168864
More information about the lldb-commits
mailing list