aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/tools/lldb-dap/stackTraceMissingModule/TestDAP_stackTraceMissingModule.py
blob: 1eb00f9935a220f37968a05e1f59ea98226d62e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Test lldb-dap stack trace when module is missing
"""

from lldbsuite.test.decorators import skipUnlessPlatform
from lldbsuite.test.lldbtest import line_number
import lldbdap_testcase
import re


class TestDAP_stackTraceMissingModule(lldbdap_testcase.DAPTestCaseBase):
    @skipUnlessPlatform(["linux"])
    def test_missingModule(self):
        """
        Test that the stack frame without a module still has assembly source.
        """
        program = self.getBuildArtifact("a.out")
        self.build_and_launch(program, commandEscapePrefix="")

        source = "main.c"
        self.set_source_breakpoints(
            source,
            [line_number(source, "// Break here")],
        )
        self.continue_to_next_stop()

        # Evaluate expr -- func
        expr_result = self.dap_server.request_evaluate(
            expression="expr -f pointer -- func",
            context="repl",
        )

        expr_result_address = re.search(
            r"0x[0-9a-fA-F]+", expr_result["body"]["result"]
        )
        self.assertIsNotNone(
            expr_result_address, "Failed to get address of dynamic allocated func"
        )
        func_address = expr_result_address.group(0)

        self.dap_server.request_evaluate(
            expression=f"breakpoint set --address {func_address}",
            context="repl",
        )

        self.continue_to_next_stop()

        frame_without_module = self.get_stackFrames()[0]

        self.assertIn("line", frame_without_module, "Line number missing.")
        self.assertIn("column", frame_without_module, "Column number missing.")
        self.assertIn("source", frame_without_module, "Source location missing.")
        source = frame_without_module["source"]
        self.assertIn("sourceReference", source, "Source reference missing.")