brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 7de85bd Raw
80 lines · python
1"""2Test lldb-dap terminated event3"""4 5import dap_server6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9import lldbdap_testcase10import re11import json12 13 14class TestDAP_terminatedEvent(lldbdap_testcase.DAPTestCaseBase):15    @skipIfWindows16    def test_terminated_event(self):17        """18        Terminated Event19        Now contains the statistics of a debug session:20        metatdata:21            totalDebugInfoByteSize > 022            totalDebugInfoEnabled > 023            totalModuleCountHasDebugInfo > 024            ...25        targetInfo:26            totalBreakpointResolveTime > 027        breakpoints:28            recognize function breakpoint29            recognize source line breakpoint30        It should contains the breakpoints info: function bp & source line bp31        """32 33        program_basename = "a.out.stripped"34        program = self.getBuildArtifact(program_basename)35        self.build_and_launch(program)36        # Set breakpoints37        functions = ["foo"]38 39        # This breakpoint will be resolved only when the libfoo module is loaded40        breakpoint_ids = self.set_function_breakpoints(41            functions, wait_for_resolve=False42        )43        self.assertEqual(len(breakpoint_ids), len(functions), "expect one breakpoint")44        main_bp_line = line_number("main.cpp", "// main breakpoint 1")45        breakpoint_ids.append(46            self.set_source_breakpoints(47                "main.cpp", [main_bp_line], wait_for_resolve=False48            )49        )50 51        self.continue_to_breakpoints(breakpoint_ids)52        self.continue_to_exit()53 54        statistics = self.dap_server.wait_for_terminated()["body"]["$__lldb_statistics"]55        self.assertGreater(statistics["totalDebugInfoByteSize"], 0)56        self.assertGreater(statistics["totalDebugInfoEnabled"], 0)57        self.assertGreater(statistics["totalModuleCountHasDebugInfo"], 0)58 59        self.assertIsNotNone(statistics["memory"])60        self.assertNotIn("modules", statistics.keys())61 62        # lldb-dap debugs one target at a time63        target = json.loads(statistics["targets"])[0]64        self.assertGreater(target["totalBreakpointResolveTime"], 0)65 66        breakpoints = target["breakpoints"]67        self.assertIn(68            "foo",69            breakpoints[0]["details"]["Breakpoint"]["BKPTResolver"]["Options"][70                "SymbolNames"71            ],72            "foo is a symbol breakpoint",73        )74        self.assertTrue(75            breakpoints[1]["details"]["Breakpoint"]["BKPTResolver"]["Options"][76                "FileName"77            ].endswith("main.cpp"),78            "target has source line breakpoint in main.cpp",79        )80