116926115SRaphael Isemannimport lldb 216926115SRaphael Isemannfrom lldbsuite.test.decorators import * 316926115SRaphael Isemannfrom lldbsuite.test.lldbtest import * 416926115SRaphael Isemannfrom lldbsuite.test import lldbutil 516926115SRaphael Isemann 616926115SRaphael Isemannclass TestCase(TestBase): 716926115SRaphael Isemann 816926115SRaphael Isemann @skipIfRemote 916926115SRaphael Isemann @skipIfWindows 1016926115SRaphael Isemann # glibc's dlopen doesn't support opening executables. 1116926115SRaphael Isemann # https://sourceware.org/bugzilla/show_bug.cgi?id=11754 1216926115SRaphael Isemann @skipIfLinux 13266c90feSMichał Górny # freebsd's dlopen ditto 1498257c30SMichał Górny @expectedFailureAll(oslist=["freebsd"]) 1599562332SMichał Górny @expectedFailureNetBSD 1616926115SRaphael Isemann @no_debug_info_test 1716926115SRaphael Isemann def test(self): 1816926115SRaphael Isemann self.build() 1916926115SRaphael Isemann # Launch and stop before the dlopen call. 2016926115SRaphael Isemann lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) 2116926115SRaphael Isemann 2216926115SRaphael Isemann # Delete the breakpoint we no longer need. 2316926115SRaphael Isemann self.target().DeleteAllBreakpoints() 2416926115SRaphael Isemann 2516926115SRaphael Isemann # Check that the executable is the test binary. 2616926115SRaphael Isemann self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 2716926115SRaphael Isemann 2816926115SRaphael Isemann # Continue so that dlopen is called. 2916926115SRaphael Isemann breakpoint = self.target().BreakpointCreateBySourceRegex( 3016926115SRaphael Isemann "// break after dlopen", lldb.SBFileSpec("main.c")) 3116926115SRaphael Isemann self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0) 3216926115SRaphael Isemann stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint) 3316926115SRaphael Isemann self.assertEqual(len(stopped_threads), 1) 3416926115SRaphael Isemann 3516926115SRaphael Isemann # Check that the executable is still the test binary and not "other". 3616926115SRaphael Isemann self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out") 3716926115SRaphael Isemann 3816926115SRaphael Isemann # Kill the process and run the program again. 3916926115SRaphael Isemann err = self.process().Kill() 40*779bbbf2SDave Lee self.assertSuccess(err) 4116926115SRaphael Isemann 4216926115SRaphael Isemann # Test that we hit the breakpoint after dlopen. 4316926115SRaphael Isemann lldbutil.run_to_breakpoint_do_run(self, self.target(), breakpoint) 44