[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 7 09:35:03 PDT 2025


JDevlieghere wrote:

> However, when lldb is used as a library, we need a way to manage opened modules to avoid problems with file locks (on some systems) for modules that we no longer need.

Can you give a concrete example? This seems like its own issue that should be solved rather than worked around. I wouldn't expect us to need to keep files open for as long as a module exists. 

> It should be possible to record all loaded modules and use `ModuleList::RemoveSharedModule` and `RemoveOrphanSharedModules` functions to clear the cache, but these functions are not available in the API. This approach is also way too complicated when we just need to cleanup the library.

This is exposed from the SB API through `SBDebugger::MemoryPressureDetected`. Not sure what's "complicated" about calling his function, but I do agree that this shouldn't necessary be an explicit operation and would make a good default. The natural place to do this is in `SBDebugger::Destroy`. You can have many debuggers and it seems like a bad idea to clear the modules when you clear one of them. 

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


More information about the lldb-commits mailing list