1import lldb 2from lldbsuite.test.decorators import * 3from lldbsuite.test.lldbtest import * 4from lldbsuite.test import lldbutil 5 6class TestCase(TestBase): 7 8 mydir = TestBase.compute_mydir(__file__) 9 10 @skipIfRemote 11 @skipIfWindows 12 # glibc's dlopen doesn't support opening executables. 13 # https://sourceware.org/bugzilla/show_bug.cgi?id=11754 14 @skipIfLinux 15 @no_debug_info_test 16 def test(self): 17 self.build() 18 # Launch and stop before the dlopen call. 19 lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) 20 21 # Delete the breakpoint we no longer need. 22 self.target().DeleteAllBreakpoints() 23 24 # Check that the executable is the test binary. 25 self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 26 27 # Continue so that dlopen is called. 28 breakpoint = self.target().BreakpointCreateBySourceRegex( 29 "// break after dlopen", lldb.SBFileSpec("main.c")) 30 self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0) 31 stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint) 32 self.assertEqual(len(stopped_threads), 1) 33 34 # Check that the executable is still the test binary and not "other". 35 self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 36 37 # Kill the process and run the program again. 38 err = self.process().Kill() 39 self.assertTrue(err.Success(), str(err)) 40 41 # Test that we hit the breakpoint after dlopen. 42 lldbutil.run_to_breakpoint_do_run(self, self.target(), breakpoint) 43