1"""
2Test lldb-vscode setBreakpoints request
3"""
4
5
6import unittest2
7import vscode
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11import lldbvscode_testcase
12
13
14class TestVSCode_setExceptionBreakpoints(
15        lldbvscode_testcase.VSCodeTestCaseBase):
16
17    mydir = TestBase.compute_mydir(__file__)
18
19    @skipIfWindows
20    @expectedFailureNetBSD
21    @skipIfRemote
22    def test_functionality(self):
23        '''Tests setting and clearing exception breakpoints.
24           This packet is a bit tricky on the debug adaptor side since there
25           is no "clear exception breakpoints" packet. Exception breakpoints
26           are set by sending a "setExceptionBreakpoints" packet with zero or
27           more exception filters. If exception breakpoints have been set
28           before, any existing breakpoints must remain set, and any new
29           breakpoints must be created, and any breakpoints that were in
30           previous requests and are not in the current request must be
31           removed. This exception tests this setting and clearing and makes
32           sure things happen correctly. It doesn't test hitting breakpoints
33           and the functionality of each breakpoint, like 'conditions' and
34           x'hitCondition' settings.
35        '''
36        # Visual Studio Code Debug Adaptors have no way to specify the file
37        # without launching or attaching to a process, so we must start a
38        # process in order to be able to set breakpoints.
39        program = self.getBuildArtifact("a.out")
40        self.build_and_launch(program)
41
42        filters = ['cpp_throw', 'cpp_catch']
43        response = self.vscode.request_setExceptionBreakpoints(filters)
44        if response:
45            self.assertTrue(response['success'])
46
47        self.continue_to_exception_breakpoint('C++ Throw')
48        self.continue_to_exception_breakpoint('C++ Catch')
49