xref: /llvm-project/lldb/test/API/lang/objc/modules-incomplete/TestIncompleteModules.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""Test that DWARF types are trusted over module types"""
2
3
4from lldbsuite.test.decorators import *
5from lldbsuite.test.lldbtest import *
6from lldbsuite.test import lldbutil
7
8
9class IncompleteModulesTestCase(TestBase):
10    def setUp(self):
11        # Call super's setUp().
12        TestBase.setUp(self)
13        # Find the line number to break inside main().
14        self.line = line_number("main.m", "// Set breakpoint 0 here.")
15
16    @add_test_categories(["gmodules"])
17    def test_expr(self):
18        self.build()
19        exe = self.getBuildArtifact("a.out")
20        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
21        lldbutil.run_break_set_by_file_and_line(
22            self, "main.m", self.line, num_expected_locations=1, loc_exact=True
23        )
24
25        self.runCmd("run", RUN_SUCCEEDED)
26
27        # The stop reason of the thread should be breakpoint.
28        self.expect(
29            "thread list",
30            STOPPED_DUE_TO_BREAKPOINT,
31            substrs=["stopped", "stop reason = breakpoint"],
32        )
33
34        # The breakpoint should have a hit count of 1.
35        lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
36
37        self.runCmd(
38            'settings set target.clang-module-search-paths "'
39            + self.getSourceDir()
40            + '"'
41        )
42
43        self.expect(
44            "expr @import myModule; 3",
45            VARIABLES_DISPLAYED_CORRECTLY,
46            substrs=["int", "3"],
47        )
48
49        self.expect(
50            "expr private_func()", VARIABLES_DISPLAYED_CORRECTLY, substrs=["int", "5"]
51        )
52
53        self.expect(
54            "expr MY_MIN(2,3)", "#defined macro was found", substrs=["int", "2"]
55        )
56
57        self.expect(
58            "expr MY_MAX(2,3)", "#undefd macro was correctly not found", error=True
59        )
60