ba8e94eddca146dc561f4d7022b6470ea9ef7e7c
[openbsd] /
1 """
2 Test that you can set breakpoint and hit the C++ language exception breakpoint
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class TestCPPExceptionBreakpoint (TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16     my_var = 10
17
18     @add_test_categories(['pyapi'])
19     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")
20     @expectedFailureNetBSD
21     def test_cpp_exception_breakpoint(self):
22         """Test setting and hitting the C++ exception breakpoint."""
23         self.build()
24         self.do_cpp_exception_bkpt()
25
26     @add_test_categories(['pyapi'])
27     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24538")
28     @expectedFailureNetBSD
29     def test_dummy_target_cpp_exception_breakpoint(self):
30         """Test setting and hitting the C++ exception breakpoint from dummy target."""
31         self.build()
32         self.do_dummy_target_cpp_exception_bkpt()
33
34     def setUp(self):
35         TestBase.setUp(self)
36         self.main_source = "main.c"
37         self.main_source_spec = lldb.SBFileSpec(self.main_source)
38
39     def do_cpp_exception_bkpt(self):
40         exe = self.getBuildArtifact("a.out")
41         error = lldb.SBError()
42
43         self.target = self.dbg.CreateTarget(exe)
44         self.assertTrue(self.target, VALID_TARGET)
45
46         exception_bkpt = self.target.BreakpointCreateForException(
47             lldb.eLanguageTypeC_plus_plus, False, True)
48         self.assertTrue(
49             exception_bkpt.IsValid(),
50             "Created exception breakpoint.")
51
52         process = self.target.LaunchSimple(
53             None, None, self.get_process_working_directory())
54         self.assertTrue(process, PROCESS_IS_VALID)
55
56         thread_list = lldbutil.get_threads_stopped_at_breakpoint(
57             process, exception_bkpt)
58         self.assertTrue(len(thread_list) == 1,
59                         "One thread stopped at the exception breakpoint.")
60
61     def do_dummy_target_cpp_exception_bkpt(self):
62         exe = self.getBuildArtifact("a.out")
63         error = lldb.SBError()
64
65         dummy_exception_bkpt = self.dbg.GetDummyTarget().BreakpointCreateForException(
66             lldb.eLanguageTypeC_plus_plus, False, True)
67         self.assertTrue(
68             dummy_exception_bkpt.IsValid(),
69             "Created exception breakpoint in dummy target.")
70
71         self.target = self.dbg.CreateTarget(exe)
72         self.assertTrue(self.target, VALID_TARGET)
73
74         exception_bkpt = self.target.GetBreakpointAtIndex(0)
75         self.assertTrue(
76             exception_bkpt.IsValid(),
77             "Target primed with exception breakpoint from dummy target.")
78
79         process = self.target.LaunchSimple(
80             None, None, self.get_process_working_directory())
81         self.assertTrue(process, PROCESS_IS_VALID)
82
83         thread_list = lldbutil.get_threads_stopped_at_breakpoint(
84            process, exception_bkpt)
85         self.assertTrue(len(thread_list) == 1,
86                        "One thread stopped at the exception breakpoint.")