[lldb/API] Expose Module::IsLoadedInTarget() to SB API (NFC)

This patch adds an `SBTarget::IsLoaded(const SBModule&) const` endpoint
to lldb's Scripting Bridge API. As the name suggests, it will allow the
user to know if the module is loaded in a specific target.

rdar://37957625

Differential Review: https://reviews.llvm.org/D95686

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani
2021-02-01 11:14:10 +00:00
parent 94fac81fcc
commit b8923c0022
4 changed files with 53 additions and 0 deletions

View File

@@ -489,3 +489,27 @@ class TargetAPITestCase(TestBase):
target3 = self.dbg.CreateTargetWithFileAndTargetTriple(exe, target.GetTriple())
self.assertTrue(target3.IsValid())
@add_test_categories(['pyapi'])
def test_is_loaded(self):
"""Exercise SBTarget.IsLoaded(SBModule&) API."""
d = {'EXE': 'b.out'}
self.build(dictionary=d)
self.setTearDownCleanup(dictionary=d)
target = self.create_simple_target('b.out')
self.assertFalse(target.IsLoaded(lldb.SBModule()))
num_modules = target.GetNumModules()
for i in range(num_modules):
module = target.GetModuleAtIndex(i)
self.assertFalse(target.IsLoaded(module), "Target that isn't "
"running shouldn't have any module loaded.")
process = target.LaunchSimple(None, None,
self.get_process_working_directory())
for i in range(num_modules):
module = target.GetModuleAtIndex(i)
self.assertTrue(target.IsLoaded(module), "Running the target should "
"have loaded its modules.")