[Lldb-commits] [lldb] Add a test for evicting unreachable modules from the global module cache (PR #74894)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 8 20:56:10 PST 2023


clayborg wrote:

> Note, I thought about adding an `SBDebugger::GetSharedModules or something, but I don't actually think that's a good thing to give external access to. Some day we should make an SBTestAPI with some useful for testing but not for the SB API library so we can make this sort of testing easier, but for this test grubbing the command output is not all that bad.

I wouldn't mind exposing such an API for the global module list as a static function on SBDebugger. One issue is that only real modules will show up here. This works fine for all modules for Darwin as executables, dSYM files and the .o files are all represented each by a lldb_private::Module. Not true for .dwo files though as they share the original module for the executable and only create a new ObjectFile, not a new Module for each. 

But this API would be useful for testing and also for people to know what modules are currently in the global module cache taking up memory in the LLDB process. To test this you might be able to do check the number of shared modules and access them if needed then run:
```
static void SBDebugger::MemoryPressureDetected();
```
As this used to get rid of orphaned modules in the past and I think it still does, then you could check this shared module count and list again to see what you found.

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


More information about the lldb-commits mailing list