2 Test that LLDB can launch a linux executable and then execs into the dynamic
3 loader into this program again.
9 from lldbsuite
.test
.decorators
import *
10 from lldbsuite
.test
.lldbtest
import *
11 from lldbsuite
.test
import lldbutil
14 class TestLinux64ExecViaDynamicLoader(TestBase
):
15 NO_DEBUG_INFO_TESTCASE
= True
17 @skipIfXmlSupportMissing
18 @skipIf(oslist
=no_match(["linux"]))
19 def test_with_svr4(self
):
20 self
.runCmd("settings set plugin.process.gdb-remote.use-libraries-svr4 true")
23 @skipIf(oslist
=no_match(["linux"]))
24 def test_without_svr4(self
):
25 self
.runCmd("settings set plugin.process.gdb-remote.use-libraries-svr4 false")
31 # Extracts path of the interpreter.
32 exe
= self
.getBuildArtifact("a.out")
34 spec
= lldb
.SBModuleSpec()
35 spec
.SetFileSpec(lldb
.SBFileSpec(exe
))
36 interp_section
= lldb
.SBModule(spec
).FindSection(".interp")
37 if not interp_section
:
39 section_data
= interp_section
.GetSectionData()
40 error
= lldb
.SBError()
41 dyld_path
= section_data
.GetString(error
, 0)
45 target
= self
.dbg
.CreateTarget(exe
)
46 self
.assertTrue(target
, VALID_TARGET
)
48 # Set a breakpoint in the main function that will get hit after the
49 # program exec's via the dynamic loader. The breakpoint will only get
50 # hit if we can successfully read the shared library lists in the
51 # DynamicLoaderPOSIXDYLD.cpp when we exec into the dynamic loader.
52 breakpoint_main
= target
.BreakpointCreateBySourceRegex(
53 "// Break here", lldb
.SBFileSpec("main.cpp")
55 # Setup our launch info to supply the dynamic loader path to the
56 # program so it gets two args:
58 # - path to dynamic loader
59 launch_info
= lldb
.SBLaunchInfo([dyld_path
])
60 error
= lldb
.SBError()
61 process
= target
.Launch(launch_info
, error
)
62 self
.assertSuccess(error
)
64 threads
= lldbutil
.get_stopped_threads(process
, lldb
.eStopReasonExec
)
65 self
.assertEqual(len(threads
), 1, "We got a thread stopped for exec.")
69 # Stopped on main here.
70 self
.assertState(process
.GetState(), lldb
.eStateStopped
)
71 thread
= process
.GetSelectedThread()
72 self
.assertIn("main", thread
.GetFrameAtIndex(0).GetDisplayFunctionName())