1 """Test the lldb public C++ api breakpoint callbacks."""
3 # __package__ = "lldbsuite.test"
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbtest
import *
9 from lldbsuite
.test
import lldbutil
13 class SBBreakpointCallbackCase(TestBase
):
14 NO_DEBUG_INFO_TESTCASE
= True
18 self
.generateSource("driver.cpp")
19 self
.generateSource("listener_test.cpp")
20 self
.generateSource("test_breakpoint_callback.cpp")
21 self
.generateSource("test_breakpoint_location_callback.cpp")
22 self
.generateSource("test_listener_event_description.cpp")
23 self
.generateSource("test_listener_event_process_state.cpp")
24 self
.generateSource("test_listener_resume.cpp")
25 self
.generateSource("test_stop-hook.cpp")
28 # clang-cl does not support throw or catch (llvm.org/pr24538)
30 def test_python_stop_hook(self
):
31 """Test that you can run a python command in a stop-hook when stdin is File based."""
32 self
.build_and_test("driver.cpp test_stop-hook.cpp", "test_python_stop_hook")
35 # clang-cl does not support throw or catch (llvm.org/pr24538)
37 def test_breakpoint_callback(self
):
38 """Test the that SBBreakpoint callback is invoked when a breakpoint is hit."""
40 "driver.cpp test_breakpoint_callback.cpp", "test_breakpoint_callback"
44 # clang-cl does not support throw or catch (llvm.org/pr24538)
46 def test_breakpoint_location_callback(self
):
47 """Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit."""
49 "driver.cpp test_breakpoint_location_callback.cpp",
50 "test_breakpoint_location_callback",
54 # clang-cl does not support throw or catch (llvm.org/pr24538)
56 @expectedFlakeyFreeBSD
57 def test_sb_api_listener_event_description(self
):
58 """Test the description of an SBListener breakpoint event is valid."""
60 "driver.cpp listener_test.cpp test_listener_event_description.cpp",
61 "test_listener_event_description",
65 # clang-cl does not support throw or catch (llvm.org/pr24538)
67 @expectedFlakeyFreeBSD
68 def test_sb_api_listener_event_process_state(self
):
69 """Test that a registered SBListener receives events when a process
73 "driver.cpp listener_test.cpp test_listener_event_process_state.cpp",
74 "test_listener_event_process_state",
78 # clang-cl does not support throw or catch (llvm.org/pr24538)
80 @expectedFlakeyFreeBSD
81 @skipIf(oslist
=["linux"]) # flakey
82 def test_sb_api_listener_resume(self
):
83 """Test that a process can be resumed from a non-main thread."""
85 "driver.cpp listener_test.cpp test_listener_resume.cpp",
86 "test_listener_resume",
89 def build_and_test(self
, sources
, test_name
, args
=None):
90 """Build LLDB test from sources, and run expecting 0 exit code"""
92 # These tests link against host lldb API.
93 # Compiler's target triple must match liblldb triple
94 # because remote is disabled, we can assume that the os is the same
95 # still need to check architecture
96 if self
.getLldbArchitecture() != self
.getArchitecture():
98 "This test is only run if the target arch is the same as the lldb binary arch"
101 self
.inferior
= "inferior_program"
102 self
.buildProgram("inferior.cpp", self
.inferior
)
103 self
.addTearDownHook(lambda: os
.remove(self
.getBuildArtifact(self
.inferior
)))
105 self
.buildDriver(sources
, test_name
)
106 self
.addTearDownHook(lambda: os
.remove(self
.getBuildArtifact(test_name
)))
108 test_exe
= self
.getBuildArtifact(test_name
)
109 self
.signBinary(test_exe
)
110 exe
= [test_exe
, self
.getBuildArtifact(self
.inferior
)]
112 env
= {self
.dylibPath
: self
.getLLDBLibraryEnvVal()}
113 if "LLDB_DEBUGSERVER_PATH" in os
.environ
:
114 env
["LLDB_DEBUGSERVER_PATH"] = os
.environ
["LLDB_DEBUGSERVER_PATH"]
117 print("Running test %s" % " ".join(exe
))
118 check_call(exe
, env
=env
)
120 with
open(os
.devnull
, "w") as fnull
:
121 check_call(exe
, env
=env
, stdout
=fnull
, stderr
=fnull
)
122 except subprocess
.CalledProcessError
as e
:
125 def build_program(self
, sources
, program
):
126 return self
.buildDriver(sources
, program
)