47 lines · python
1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5 6 7class TestCase(TestBase):8 @skipIfRemote9 @skipIfWindows10 # glibc's dlopen doesn't support opening executables.11 # https://sourceware.org/bugzilla/show_bug.cgi?id=1175412 @skipIfLinux13 # freebsd's dlopen ditto14 @expectedFailureAll(oslist=["freebsd"])15 @expectedFailureNetBSD16 @no_debug_info_test17 def test(self):18 self.build()19 # Launch and stop before the dlopen call.20 lldbutil.run_to_source_breakpoint(21 self, "// break here", lldb.SBFileSpec("main.c")22 )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 )34 self.assertNotEqual(breakpoint.GetNumResolvedLocations(), 0)35 stopped_threads = lldbutil.continue_to_breakpoint(self.process(), breakpoint)36 self.assertEqual(len(stopped_threads), 1)37 38 # Check that the executable is still the test binary and not "other".39 self.assertEqual(self.target().GetExecutable().GetFilename(), "a.out")40 41 # Kill the process and run the program again.42 err = self.process().Kill()43 self.assertSuccess(err)44 45 # Test that we hit the breakpoint after dlopen.46 lldbutil.run_to_breakpoint_do_run(self, self.target(), breakpoint)47