1"""
2Test stop hooks
3"""
4
5
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8import lldbvscode_testcase
9
10
11class TestVSCode_stop_hooks(lldbvscode_testcase.VSCodeTestCaseBase):
12
13    @skipIfRemote
14    def test_stop_hooks_before_run(self):
15        '''
16            Test that there is no race condition between lldb-vscode and
17            stop hooks executor
18        '''
19        program = self.getBuildArtifact("a.out")
20        preRunCommands = ['target stop-hook add -o help']
21        self.build_and_launch(program, stopOnEntry=True, preRunCommands=preRunCommands)
22
23        # The first stop is on entry.
24        self.continue_to_next_stop()
25
26        breakpoint_ids = self.set_function_breakpoints(['main'])
27        # This request hangs if the race happens, because, in that case, the
28        # command interpreter is in synchronous mode while lldb-vscode expects
29        # it to be in asynchronous mode, so, the process doesn't send the stop
30        # event to "lldb.Debugger" listener (which is monitored by lldb-vscode).
31        self.continue_to_breakpoints(breakpoint_ids)
32
33        self.continue_to_exit()
34