[Lldb-commits] [lldb] [lldb][windows] support long path in loaded modules cache (PR #206117)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 15 04:30:59 PDT 2026


charles-zablit wrote:

> I don't think that this is a good idea. This enables long paths at the cost of valid image enumeration. `EnumProcessModulesEx` is not thread safe and that means that the process may have changed its module list _during_ iteration.
> 
> While ToolHlp32 has its own set of issues, you are certain that the snapshot itself is valid.
> 
> I think that you should instead address `FileSystem::Resolve` to use `GetModuleHandleExW` with `GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT` with the `me.modBaseAddr` and then use `GetFinalPathNameByHandleW` with `VOLUME_NAME_NT | FILE_NAME_NORMALIZED` to get the long path name.

We can't use `GetModuleHandleExW` because it only resolves modules loaded by lldb, not the debuggee:

> The module must have been loaded by the calling process.

https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandleexw

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


More information about the lldb-commits mailing list