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