2 Test that LLDB can launch a linux executable through the dynamic loader and still hit a breakpoint.
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class TestLinux64LaunchingViaDynamicLoader(TestBase
):
14 @skipIf(oslist
=no_match(["linux"]))
16 @skipIf(oslist
=["linux"], archs
=["arm"])
20 # Extracts path of the interpreter.
21 spec
= lldb
.SBModuleSpec()
22 spec
.SetFileSpec(lldb
.SBFileSpec(self
.getBuildArtifact("a.out")))
23 interp_section
= lldb
.SBModule(spec
).FindSection(".interp")
24 if not interp_section
:
26 section_data
= interp_section
.GetSectionData()
27 error
= lldb
.SBError()
28 exe
= section_data
.GetString(error
, 0)
32 target
= self
.dbg
.CreateTarget(exe
)
33 self
.assertTrue(target
, VALID_TARGET
)
35 # Set breakpoints both on shared library function as well as on
36 # main. Both of them will be pending breakpoints.
37 breakpoint_main
= target
.BreakpointCreateBySourceRegex(
38 "// Break here", lldb
.SBFileSpec("main.cpp")
40 breakpoint_shared_library
= target
.BreakpointCreateBySourceRegex(
41 "get_signal_crash", lldb
.SBFileSpec("signal_file.cpp")
43 inferior_exe_path
= lldbutil
.install_to_target(
44 self
, self
.getBuildArtifact("a.out")
46 lldbutil
.install_to_target(self
, self
.getBuildArtifact("libsignal_file.so"))
48 launch_info
= lldb
.SBLaunchInfo(
51 self
.get_process_working_directory(),
55 launch_info
.SetWorkingDirectory(self
.get_process_working_directory())
56 error
= lldb
.SBError()
57 process
= target
.Launch(launch_info
, error
)
58 self
.assertSuccess(error
)
60 # Stopped on main here.
61 self
.assertState(process
.GetState(), lldb
.eStateStopped
)
62 thread
= process
.GetSelectedThread()
63 self
.assertIn("main", thread
.GetFrameAtIndex(0).GetDisplayFunctionName())
66 # Stopped on get_signal_crash function here.
67 self
.assertState(process
.GetState(), lldb
.eStateStopped
)
69 "get_signal_crash", thread
.GetFrameAtIndex(0).GetDisplayFunctionName()
73 # Stopped because of generated signal.
74 self
.assertState(process
.GetState(), lldb
.eStateStopped
)
75 self
.assertIn("raise", lldbutil
.get_function_names(thread
))