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 # freebsd's dlopen ditto 16 @expectedFailureAll(oslist=["freebsd"]) 17 @expectedFailureNetBSD 18 @no_debug_info_test 19 def test(self): 20 self.build() 21 # Launch and stop before the dlopen call. 22 lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) 23 24 # Delete the breakpoint we no longer need. 25 self.target().DeleteAllBreakpoints() 26 27 # Check that the executable is the test binary. 28 self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 29 30 # Continue so that dlopen is called. 31 breakpoint = self.target().BreakpointCreateBySourceRegex( 32 "// break after dlopen", lldb.SBFileSpec("main.c")) 33 self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0) 34 stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint) 35 self.assertEqual(len(stopped_threads), 1) 36 37 # Check that the executable is still the test binary and not "other". 38 self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 39 40 # Kill the process and run the program again. 41 err = self.process().Kill() 42 self.assertSuccess(err) 43 44 # Test that we hit the breakpoint after dlopen. 45 lldbutil.run_to_breakpoint_do_run(self, self.target(), breakpoint) 46