JDevlieghere wrote:

> How should a proper debugger shutdown sequence look like?
> 
> 1. Release all `SBModule` pointers.
> 2. Call `SBDebugger::MemoryPressureDetected`.
> 3. Call `SBDebugger::Destroy`.

Ideally, `SBDebugger::Destroy` would clean up all the modules in the module 
cache. You say we don't do that and that we leak them intentionally, which 
suggests that we don't do that on purpose. It'd be interesting to understand 
why, but I think that's fundamentally at odds with what you're trying to 
achieve. If there's a "good" reason and changing that is not an option, 
`SBDebugger::MemoryPressureDetected` could be an escape hatch. 

> `SBDebugger::MemoryPressureDetected` only removes shared pointers to modules 
> with `use_count == 1`. Assuming that the calling program releases all its 
> modules in (1), we need to make sure that the debugger does not keep any 
> pointers elsewhere before (2). Can we rely on this?

Yes, if you destroyed all the debuggers and don't hold onto modules yourself, 
that should release all the modules. We actually test for this after every test 
in our test suite. 

https://github.com/llvm/llvm-project/pull/147289
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to