55 lines · python
1"""2Test lldb-dap stack trace when module is missing3"""4 5from lldbsuite.test.decorators import skipUnlessPlatform6from lldbsuite.test.lldbtest import line_number7import lldbdap_testcase8import re9 10 11class TestDAP_stackTraceMissingModule(lldbdap_testcase.DAPTestCaseBase):12 @skipUnlessPlatform(["linux"])13 def test_missingModule(self):14 """15 Test that the stack frame without a module still has assembly source.16 """17 program = self.getBuildArtifact("a.out")18 self.build_and_launch(program, commandEscapePrefix="")19 20 source = "main.c"21 self.set_source_breakpoints(22 source,23 [line_number(source, "// Break here")],24 )25 self.continue_to_next_stop()26 27 # Evaluate expr -- func28 expr_result = self.dap_server.request_evaluate(29 expression="expr -f pointer -- func",30 context="repl",31 )32 33 expr_result_address = re.search(34 r"0x[0-9a-fA-F]+", expr_result["body"]["result"]35 )36 self.assertIsNotNone(37 expr_result_address, "Failed to get address of dynamic allocated func"38 )39 func_address = expr_result_address.group(0)40 41 self.dap_server.request_evaluate(42 expression=f"breakpoint set --address {func_address}",43 context="repl",44 )45 46 self.continue_to_next_stop()47 48 frame_without_module = self.get_stackFrames()[0]49 50 self.assertIn("line", frame_without_module, "Line number missing.")51 self.assertIn("column", frame_without_module, "Column number missing.")52 self.assertIn("source", frame_without_module, "Source location missing.")53 source = frame_without_module["source"]54 self.assertIn("sourceReference", source, "Source reference missing.")55