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