brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 3b769d2 Raw
58 lines · python
1"""2Test lldb-dap variables/stackTrace request for optimized code3"""4 5import dap_server6import lldbdap_testcase7from lldbsuite.test import lldbutil8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10 11 12class TestDAP_optimized(lldbdap_testcase.DAPTestCaseBase):13    @skipIfWindows14    def test_stack_frame_name(self):15        """Test optimized frame has special name suffix."""16        program = self.getBuildArtifact("a.out")17        self.build_and_launch(program)18        source = "main.cpp"19        breakpoint_line = line_number(source, "// breakpoint 1")20        lines = [breakpoint_line]21        breakpoint_ids = self.set_source_breakpoints(source, lines)22        self.assertEqual(23            len(breakpoint_ids), len(lines), "expect correct number of breakpoints"24        )25        self.continue_to_breakpoints(breakpoint_ids)26        leaf_frame = self.dap_server.get_stackFrame(frameIndex=0)27        self.assertTrue(leaf_frame["name"].endswith(" [opt]"))28        parent_frame = self.dap_server.get_stackFrame(frameIndex=1)29        self.assertTrue(parent_frame["name"].endswith(" [opt]"))30 31    @skipIfAsan  # On ASAN builds this test intermittently fails https://github.com/llvm/llvm-project/issues/11106132    @skipIfWindows33    def test_optimized_variable(self):34        """Test optimized variable value contains error."""35        program = self.getBuildArtifact("a.out")36        self.build_and_launch(program)37        source = "main.cpp"38        breakpoint_line = line_number(source, "// breakpoint 2")39        lines = [breakpoint_line]40        # Set breakpoint in the thread function so we can step the threads41        breakpoint_ids = self.set_source_breakpoints(source, lines)42        self.assertEqual(43            len(breakpoint_ids), len(lines), "expect correct number of breakpoints"44        )45        self.continue_to_breakpoints(breakpoint_ids)46        optimized_variable = self.dap_server.get_local_variable("argc")47 48        value: str = optimized_variable["value"]49        self.assertTrue(50            value.startswith("<error:"),51            f"expect error for value: '{value}'",52        )53        self.assertTrue(54            ("could not evaluate DW_OP_entry_value: no parent function" in value)55            or ("variable not available" in value)56        )57        self.continue_to_exit()58