mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-26 09:49:48 +00:00
[lldb/Test] Assert that no targets or modules remain after a test completes.
The reproducer intentionally leak every object allocated during replay, which means that modules never get orphaned. If this were to happen for another reason, we might not be testing what we think we are. Assert that there are no targets left at the end of a test and that the global module cache is empty in the non-reproducer scenario. Differential revision: https://reviews.llvm.org/D81612
This commit is contained in:
parent
bb2f6f66c7
commit
da601ea731
@ -344,6 +344,15 @@ public:
|
|||||||
lldb::SBAddress
|
lldb::SBAddress
|
||||||
GetObjectFileEntryPointAddress() const;
|
GetObjectFileEntryPointAddress() const;
|
||||||
|
|
||||||
|
%feature("docstring", "
|
||||||
|
Returns the number of modules in the module cache. This is an
|
||||||
|
implementation detail exposed for testing and should not be relied upon.
|
||||||
|
|
||||||
|
@return
|
||||||
|
The number of modules in the module cache.") GetNumberAllocatedModules;
|
||||||
|
static uint32_t
|
||||||
|
GetNumberAllocatedModules();
|
||||||
|
|
||||||
STRING_EXTENSION(SBModule)
|
STRING_EXTENSION(SBModule)
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
#ifdef SWIGPYTHON
|
||||||
|
@ -288,6 +288,9 @@ public:
|
|||||||
lldb::SBAddress GetObjectFileHeaderAddress() const;
|
lldb::SBAddress GetObjectFileHeaderAddress() const;
|
||||||
lldb::SBAddress GetObjectFileEntryPointAddress() const;
|
lldb::SBAddress GetObjectFileEntryPointAddress() const;
|
||||||
|
|
||||||
|
/// Get the number of global modules.
|
||||||
|
static uint32_t GetNumberAllocatedModules();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SBAddress;
|
friend class SBAddress;
|
||||||
friend class SBFrame;
|
friend class SBFrame;
|
||||||
|
@ -2018,10 +2018,18 @@ class TestBase(Base):
|
|||||||
process = target.GetProcess()
|
process = target.GetProcess()
|
||||||
if process:
|
if process:
|
||||||
rc = self.invoke(process, "Kill")
|
rc = self.invoke(process, "Kill")
|
||||||
self.assertTrue(rc.Success(), PROCESS_KILLED)
|
assert rc.Success()
|
||||||
for target in targets:
|
for target in targets:
|
||||||
self.dbg.DeleteTarget(target)
|
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
|
||||||
|
|
||||||
# Do this last, to make sure it's in reverse order from how we setup.
|
# Do this last, to make sure it's in reverse order from how we setup.
|
||||||
Base.tearDown(self)
|
Base.tearDown(self)
|
||||||
|
|
||||||
|
@ -683,6 +683,13 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const {
|
|||||||
return LLDB_RECORD_RESULT(sb_addr);
|
return LLDB_RECORD_RESULT(sb_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t SBModule::GetNumberAllocatedModules() {
|
||||||
|
LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
|
||||||
|
GetNumberAllocatedModules);
|
||||||
|
|
||||||
|
return Module::GetNumberAllocatedModules();
|
||||||
|
}
|
||||||
|
|
||||||
namespace lldb_private {
|
namespace lldb_private {
|
||||||
namespace repro {
|
namespace repro {
|
||||||
|
|
||||||
@ -757,6 +764,8 @@ void RegisterMethods<SBModule>(Registry &R) {
|
|||||||
GetObjectFileHeaderAddress, ());
|
GetObjectFileHeaderAddress, ());
|
||||||
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
|
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
|
||||||
GetObjectFileEntryPointAddress, ());
|
GetObjectFileEntryPointAddress, ());
|
||||||
|
LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
|
||||||
|
());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user