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    @skipIfRemote
21    def test_functionality(self):
22        '''Tests setting and clearing exception breakpoints.
23           This packet is a bit tricky on the debug adaptor side since there
24           is no "clear exception breakpoints" packet. Exception breakpoints
25           are set by sending a "setExceptionBreakpoints" packet with zero or
26           more exception filters. If exception breakpoints have been set
27           before, any existing breakpoints must remain set, and any new
28           breakpoints must be created, and any breakpoints that were in
29           previous requests and are not in the current request must be
30           removed. This exception tests this setting and clearing and makes
31           sure things happen correctly. It doesn't test hitting breakpoints
32           and the functionality of each breakpoint, like 'conditions' and
33           x'hitCondition' settings.
34        '''
35        # Visual Studio Code Debug Adaptors have no way to specify the file
36        # without launching or attaching to a process, so we must start a
37        # process in order to be able to set breakpoints.
38        program = self.getBuildArtifact("a.out")
39        self.build_and_launch(program)
40
41        filters = ['cpp_throw', 'cpp_catch']
42        response = self.vscode.request_setExceptionBreakpoints(filters)
43        if response:
44            self.assertTrue(response['success'])
45
46        self.continue_to_exception_breakpoint('C++ Throw')
47        self.continue_to_exception_breakpoint('C++ Catch')
48