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