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