brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · ddedf7a Raw
65 lines · python
1"""2Test exception behavior in DAP with obj-c throw.3"""4 5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7import lldbdap_testcase8 9 10class TestDAP_exception_objc(lldbdap_testcase.DAPTestCaseBase):11    @skipUnlessDarwin12    def test_stopped_description(self):13        """14        Test that exception description is shown correctly in stopped event.15        """16        program = self.getBuildArtifact("a.out")17        self.build_and_launch(program)18        self.dap_server.request_continue()19        self.assertTrue(self.verify_stop_exception_info("signal SIGABRT"))20        exception_info = self.get_exceptionInfo()21        self.assertEqual(exception_info["breakMode"], "always")22        self.assertEqual(exception_info["description"], "signal SIGABRT")23        self.assertEqual(exception_info["exceptionId"], "signal")24        exception_details = exception_info["details"]25        self.assertRegex(exception_details["message"], "SomeReason")26        self.assertRegex(exception_details["stackTrace"], "main.m")27 28    @skipUnlessDarwin29    def test_break_on_throw_and_catch(self):30        """31        Test that breakpoints on exceptions work as expected.32        """33        program = self.getBuildArtifact("a.out")34        self.build_and_launch(program)35 36        response = self.dap_server.request_setExceptionBreakpoints(37            filter_options=[38                {39                    "filterId": "objc_throw",40                    "condition": '[[((NSException *)$arg1) name] isEqual:@"ThrownException"]',41                },42            ]43        )44        if response:45            self.assertTrue(response["success"])46 47        self.continue_to_exception_breakpoint("Objective-C Throw")48 49        # FIXME: Catching objc exceptions do not appear to be working.50        # Xcode appears to set a breakpoint on '__cxa_begin_catch' for objc51        # catch, which is different than52        # SBTarget::BreakpointCreateForException(eLanguageObjectiveC, /*catch_bp=*/true, /*throw_bp=*/false);53        # self.continue_to_exception_breakpoint("Objective-C Catch")54 55        self.do_continue()56 57        self.assertTrue(self.verify_stop_exception_info("signal SIGABRT"))58        exception_info = self.get_exceptionInfo()59        self.assertEqual(exception_info["breakMode"], "always")60        self.assertEqual(exception_info["description"], "signal SIGABRT")61        self.assertEqual(exception_info["exceptionId"], "signal")62        exception_details = exception_info["details"]63        self.assertRegex(exception_details["message"], "SomeReason")64        self.assertRegex(exception_details["stackTrace"], "main.m")65