Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / dyld-launch-linux / TestDyldLaunchLinux.py
blob26360c20db1e206334f5613b798c710df93df899
1 """
2 Test that LLDB can launch a linux executable through the dynamic loader and still hit a breakpoint.
3 """
5 import lldb
6 import os
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
12 class TestLinux64LaunchingViaDynamicLoader(TestBase):
13 @skipIf(oslist=no_match(["linux"]))
14 @no_debug_info_test
15 @skipIf(oslist=["linux"], archs=["arm"])
16 def test(self):
17 self.build()
19 # Extracts path of the interpreter.
20 spec = lldb.SBModuleSpec()
21 spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out")))
22 interp_section = lldb.SBModule(spec).FindSection(".interp")
23 if not interp_section:
24 return
25 section_data = interp_section.GetSectionData()
26 error = lldb.SBError()
27 exe = section_data.GetString(error, 0)
28 if error.Fail():
29 return
31 target = self.dbg.CreateTarget(exe)
32 self.assertTrue(target, VALID_TARGET)
34 # Set breakpoints both on shared library function as well as on
35 # main. Both of them will be pending breakpoints.
36 breakpoint_main = target.BreakpointCreateBySourceRegex(
37 "// Break here", lldb.SBFileSpec("main.cpp")
39 breakpoint_shared_library = target.BreakpointCreateBySourceRegex(
40 "get_signal_crash", lldb.SBFileSpec("signal_file.cpp")
42 launch_info = lldb.SBLaunchInfo(
44 "--library-path",
45 self.get_process_working_directory(),
46 self.getBuildArtifact("a.out"),
49 launch_info.SetWorkingDirectory(self.get_process_working_directory())
50 error = lldb.SBError()
51 process = target.Launch(launch_info, error)
52 self.assertSuccess(error)
54 # Stopped on main here.
55 self.assertState(process.GetState(), lldb.eStateStopped)
56 thread = process.GetSelectedThread()
57 self.assertIn("main", thread.GetFrameAtIndex(0).GetDisplayFunctionName())
58 process.Continue()
60 # Stopped on get_signal_crash function here.
61 self.assertState(process.GetState(), lldb.eStateStopped)
62 self.assertIn(
63 "get_signal_crash", thread.GetFrameAtIndex(0).GetDisplayFunctionName()
65 process.Continue()
67 # Stopped because of generated signal.
68 self.assertState(process.GetState(), lldb.eStateStopped)
69 self.assertIn("raise", lldbutil.get_function_names(thread))