[Lldb-commits] [PATCH] D83876: [lldb] Clean orphaned modules in Debugger::Destroy
Raphael Isemann via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 15 08:00:34 PDT 2020
teemperor created this revision.
teemperor added reviewers: JDevlieghere, labath, LLDB.
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. 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 makes that also SBDebugger::Destroy is cleaning orphaned lldb:: ModuleSP instances. It also moves that sanity
check behind the SBDebugger::Destroy in our test suite to make this work.
This fixes TestUnicodeSymbols.py when D83865 <https://reviews.llvm.org/D83865> is applied (which makes that the sanity checks actually fail the test).
Repository:
rLLDB LLDB
https://reviews.llvm.org/D83876
Files:
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/Core/Debugger.cpp
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -600,10 +600,14 @@
for (pos = g_debugger_list_ptr->begin(); pos != end; ++pos) {
if ((*pos).get() == debugger_sp.get()) {
g_debugger_list_ptr->erase(pos);
- return;
+ break;
}
}
}
+
+ // Clean any modules that are orphaned.
+ bool mandatory = true;
+ ModuleList::RemoveOrphanSharedModules(mandatory);
}
DebuggerSP Debugger::FindDebuggerWithInstanceName(ConstString instance_name) {
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1058,6 +1058,13 @@
lldb.SBDebugger.Destroy(self.dbg)
del self.dbg
+ # Modules are not orphaned during reproducer replay because they're
+ # leaked on purpose.
+ if not configuration.is_reproducer():
+ # Assert that the global module cache is empty.
+ self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
+
+
# =========================================================
# Various callbacks to allow introspection of test progress
# =========================================================
@@ -2021,13 +2028,9 @@
for target in targets:
self.dbg.DeleteTarget(target)
- # Modules are not orphaned during reproducer replay because they're
- # leaked on purpose.
if not configuration.is_reproducer():
# Assert that all targets are deleted.
- assert self.dbg.GetNumTargets() == 0
- # Assert that the global module cache is empty.
- assert lldb.SBModule.GetNumberAllocatedModules() == 0
+ self.assertEqual(self.dbg.GetNumTargets(), 0)
# Do this last, to make sure it's in reverse order from how we setup.
Base.tearDown(self)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83876.278186.patch
Type: text/x-patch
Size: 2075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200715/8043263b/attachment-0001.bin>
More information about the lldb-commits
mailing list