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