1""" 2Test lldb-dap terminated event 3""" 4 5import dap_server 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9import lldbdap_testcase 10import re 11import json 12 13 14class TestDAP_terminatedEvent(lldbdap_testcase.DAPTestCaseBase): 15 @skipIfWindows 16 def test_terminated_event(self): 17 """ 18 Terminated Event 19 Now contains the statistics of a debug session: 20 metatdata: 21 totalDebugInfoByteSize > 0 22 totalDebugInfoEnabled > 0 23 totalModuleCountHasDebugInfo > 0 24 ... 25 targetInfo: 26 totalBreakpointResolveTime > 0 27 breakpoints: 28 recognize function breakpoint 29 recognize source line breakpoint 30 It should contains the breakpoints info: function bp & source line bp 31 """ 32 33 program_basename = "a.out.stripped" 34 program = self.getBuildArtifact(program_basename) 35 self.build_and_launch(program) 36 # Set breakpoints 37 functions = ["foo"] 38 breakpoint_ids = self.set_function_breakpoints(functions) 39 self.assertEqual(len(breakpoint_ids), len(functions), "expect one breakpoint") 40 main_bp_line = line_number("main.cpp", "// main breakpoint 1") 41 breakpoint_ids.append(self.set_source_breakpoints("main.cpp", [main_bp_line])) 42 43 self.continue_to_breakpoints(breakpoint_ids) 44 self.continue_to_exit() 45 46 statistics = self.dap_server.wait_for_terminated()["statistics"] 47 self.assertGreater(statistics["totalDebugInfoByteSize"], 0) 48 self.assertGreater(statistics["totalDebugInfoEnabled"], 0) 49 self.assertGreater(statistics["totalModuleCountHasDebugInfo"], 0) 50 51 self.assertIsNotNone(statistics["memory"]) 52 self.assertNotIn("modules", statistics.keys()) 53 54 # lldb-dap debugs one target at a time 55 target = json.loads(statistics["targets"])[0] 56 self.assertGreater(target["totalBreakpointResolveTime"], 0) 57 58 breakpoints = target["breakpoints"] 59 self.assertIn( 60 "foo", 61 breakpoints[0]["details"]["Breakpoint"]["BKPTResolver"]["Options"][ 62 "SymbolNames" 63 ], 64 "foo is a symbol breakpoint", 65 ) 66 self.assertTrue( 67 breakpoints[1]["details"]["Breakpoint"]["BKPTResolver"]["Options"][ 68 "FileName" 69 ].endswith("main.cpp"), 70 "target has source line breakpoint in main.cpp", 71 ) 72