summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBModule.cpp
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2020-08-17 10:56:02 +0200
committerRaphael Isemann <teemperor@gmail.com>2020-08-17 11:00:19 +0200
commitc2f9454a16e45e1df09d8ebed6dadbc0da264442 (patch)
tree88b80395d987d0dfb40616e2a42adfc0b83f0946 /lldb/source/API/SBModule.cpp
parent867c347c32e27825a649af1ca5ccf22c350d2b8c (diff)
[lldb] Add SBModule::GarbageCollectAllocatedModules and clear modules after each test run
Right now the only places in the SB API where lldb:: ModuleSP instances are destroyed are in SBDebugger::MemoryPressureDetected (where it's just attempted but not guaranteed) and in SBDebugger::DeleteTarget (which will be removed in D83933). Tests that directly create an lldb::ModuleSP and never create a target therefore currently leak lldb::Module instances. This triggers the sanity checks in lldbtest that make sure that the global module list is empty after a test. This patch adds SBModule::GarbageCollectAllocatedModules as an explicit way to clean orphaned lldb::ModuleSP instances. Also we now start calling this method at the end of each test run and move the sanity check behind that call to make this work. This way even tests that don't create targets can pass the sanity check. This fixes TestUnicodeSymbols.py when D83865 is applied (which makes that the sanity checks actually fail the test). Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D83876
Diffstat (limited to 'lldb/source/API/SBModule.cpp')
-rw-r--r--lldb/source/API/SBModule.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index c30529b37eb1..883319b8078c 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -690,6 +690,13 @@ uint32_t SBModule::GetNumberAllocatedModules() {
return Module::GetNumberAllocatedModules();
}
+void SBModule::GarbageCollectAllocatedModules() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBModule,
+ GarbageCollectAllocatedModules);
+ const bool mandatory = false;
+ ModuleList::RemoveOrphanSharedModules(mandatory);
+}
+
namespace lldb_private {
namespace repro {