1""" 2Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY 3""" 4 5 6 7import os 8import shutil 9import lldb 10from lldbsuite.test.decorators import * 11from lldbsuite.test.lldbtest import * 12from lldbsuite.test import lldbutil 13 14 15@skipIfRemote 16@skipIfWindows # The Windows platform doesn't implement DoLoadImage. 17class LoadUsingLazyBind(TestBase): 18 19 mydir = TestBase.compute_mydir(__file__) 20 21 NO_DEBUG_INFO_TESTCASE = True 22 23 def setUp(self): 24 # Call super's setUp(). 25 TestBase.setUp(self) 26 27 # Invoke the default build rule. 28 self.build() 29 30 self.wd = os.path.realpath(self.getBuildDir()) 31 32 self.ext = 'so' 33 if self.platformIsDarwin(): 34 self.ext = 'dylib' 35 36 # Overwrite t2_0 with t2_1 to delete the definition of `use`. 37 shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.format(self.ext)), 38 os.path.join(self.wd, 'libt2_0.{}'.format(self.ext))) 39 40 @skipIfRemote 41 @skipIfWindows # The Windows platform doesn't implement DoLoadImage. 42 def test_load_using_lazy_bind(self): 43 """Test that we load using RTLD_LAZY""" 44 45 (target, process, thread, _) = lldbutil.run_to_source_breakpoint(self, 46 "break here", 47 lldb.SBFileSpec("main.cpp")) 48 error = lldb.SBError() 49 lib_spec = lldb.SBFileSpec("libt1.{}".format(self.ext)) 50 paths = lldb.SBStringList() 51 paths.AppendString(self.wd) 52 out_spec = lldb.SBFileSpec() 53 token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error) 54 self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token") 55