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