xref: /llvm-project/lldb/test/API/lang/cpp/gmodules/pch-chain/TestPchChain.py (revision 252f3c98db1383ee0e1f25020d488ffb7b4ac392)
1"""
2Tests that we correctly track AST layout info
3(specifically alignment) when moving AST nodes
4between several ClangASTImporter instances
5(in this case, from a pch chain to executable
6to expression AST).
7"""
8
9import lldb
10import os
11from lldbsuite.test.decorators import *
12from lldbsuite.test.lldbtest import *
13from lldbsuite.test import lldbutil
14
15
16class TestPchChain(TestBase):
17    @add_test_categories(["gmodules"])
18    @expectedFailureAll("Chained pch debugging currently not fully supported")
19    def test_expr(self):
20        self.build()
21        exe = self.getBuildArtifact("a.out")
22        self.target = self.dbg.CreateTarget(exe)
23        self.assertTrue(self.target, VALID_TARGET)
24        lldbutil.run_break_set_by_file_and_line(
25            self, "main.cpp", 9, num_expected_locations=1
26        )
27
28        self.runCmd("run", RUN_SUCCEEDED)
29
30        self.expect(
31            "frame variable data",
32            substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"],
33        )
34
35    @add_test_categories(["gmodules"])
36    @expectedFailureAll("Chained pch debugging currently not fully supported")
37    def test_frame_var(self):
38        self.build()
39        exe = self.getBuildArtifact("a.out")
40        self.target = self.dbg.CreateTarget(exe)
41        self.assertTrue(self.target, VALID_TARGET)
42        lldbutil.run_break_set_by_file_and_line(
43            self, "main.cpp", 9, num_expected_locations=1
44        )
45
46        self.runCmd("run", RUN_SUCCEEDED)
47
48        self.expect_expr(
49            "data",
50            result_type="MatrixData",
51            result_children=[
52                ValueCheck(
53                    name="section",
54                    children=[
55                        ValueCheck(
56                            name="origin",
57                            children=[
58                                ValueCheck(name="row", value="1"),
59                                ValueCheck(name="col", value="2"),
60                            ],
61                        ),
62                        ValueCheck(
63                            name="size",
64                            children=[
65                                ValueCheck(name="row", value="3"),
66                                ValueCheck(name="col", value="4"),
67                            ],
68                        ),
69                    ],
70                ),
71                ValueCheck(name="stride", value="5"),
72            ],
73        )
74