brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · e8e07e1 Raw
106 lines · python
1"""2Test lldb-dap RestartRequest.3"""4 5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import line_number7import lldbdap_testcase8 9 10class TestDAP_restart(lldbdap_testcase.DAPTestCaseBase):11    @skipIfWindows12    def test_basic_functionality(self):13        """14        Tests the basic restarting functionality: set two breakpoints in15        sequence, restart at the second, check that we hit the first one.16        """17        line_A = line_number("main.c", "// breakpoint A")18        line_B = line_number("main.c", "// breakpoint B")19 20        program = self.getBuildArtifact("a.out")21        self.build_and_launch(program)22        [bp_A, bp_B] = self.set_source_breakpoints("main.c", [line_A, line_B])23 24        # Verify we hit A, then B.25        self.continue_to_breakpoints([bp_A])26        self.continue_to_breakpoints([bp_B])27 28        # Make sure i has been modified from its initial value of 0.29        self.assertEqual(30            int(self.dap_server.get_local_variable_value("i")),31            1234,32            "i != 1234 after hitting breakpoint B",33        )34 35        # Restart then check we stop back at A and program state has been reset.36        resp = self.dap_server.request_restart()37        self.assertTrue(resp["success"])38        self.verify_breakpoint_hit([bp_A])39        self.assertEqual(40            int(self.dap_server.get_local_variable_value("i")),41            0,42            "i != 0 after hitting breakpoint A on restart",43        )44 45    @skipIfWindows46    def test_stopOnEntry(self):47        """48        Check that the stopOnEntry setting is still honored after a restart.49        """50        program = self.getBuildArtifact("a.out")51        self.build_and_launch(program, stopOnEntry=True)52        [bp_main] = self.set_function_breakpoints(["main"])53 54        self.continue_to_next_stop()55        self.verify_stop_on_entry()56 57        # Then, if we continue, we should hit the breakpoint at main.58        self.continue_to_breakpoints([bp_main])59 60        # Restart and check that we still get a stopped event before reaching61        # main.62        resp = self.dap_server.request_restart()63        self.assertTrue(resp["success"])64        self.verify_stop_on_entry()65 66    @skipIfWindows67    def test_arguments(self):68        """69        Tests that lldb-dap will use updated launch arguments included70        with a restart request.71        """72        line_A = line_number("main.c", "// breakpoint A")73 74        program = self.getBuildArtifact("a.out")75        self.build_and_launch(program)76        [bp_A] = self.set_source_breakpoints("main.c", [line_A])77 78        # Verify we hit A, then B.79        self.continue_to_breakpoints([bp_A])80 81        # We don't set any arguments in the initial launch request, so argc82        # should be 1.83        self.assertEqual(84            int(self.dap_server.get_local_variable_value("argc")),85            1,86            "argc != 1 before restart",87        )88 89        # Restart with some extra 'args' and check that the new argc reflects90        # the updated launch config.91        resp = self.dap_server.request_restart(92            restartArguments={93                "arguments": {94                    "program": program,95                    "args": ["a", "b", "c", "d"],96                }97            }98        )99        self.assertTrue(resp["success"])100        self.verify_breakpoint_hit([bp_A])101        self.assertEqual(102            int(self.dap_server.get_local_variable_value("argc")),103            5,104            "argc != 5 after restart",105        )106