blob: f475a0625d2f83eaa7a63c54629b0e4142a93edb [file] [log] [blame]
Sean Callanan85054342015-04-03 15:39:47 +00001"""Test that DWARF types are trusted over module types"""
2
3import os, time
4import unittest2
5import lldb
6import platform
7import lldbutil
8
9from distutils.version import StrictVersion
10
11from lldbtest import *
12
13class IncompleteModulesTestCase(TestBase):
14
15 mydir = TestBase.compute_mydir(__file__)
16
17 @skipUnlessDarwin
18 @dsym_test
19 def test_expr_with_dsym(self):
20 self.buildDsym()
21 self.expr()
22
23 @dwarf_test
24 @skipIfFreeBSD
25 @skipIfLinux
26 def test_expr_with_dwarf(self):
27 self.buildDwarf()
28 self.expr()
29
30 def setUp(self):
31 # Call super's setUp().
32 TestBase.setUp(self)
33 # Find the line number to break inside main().
34 self.line = line_number('main.m', '// Set breakpoint 0 here.')
35
36 def applies(self):
37 if platform.system() != "Darwin":
38 return False
39 if StrictVersion('12.0.0') > platform.release():
40 return False
41
42 return True
43
44 def common_setup(self):
45 exe = os.path.join(os.getcwd(), "a.out")
46 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
47
48 # Break inside the foo function which takes a bar_ptr argument.
49 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
50
51 self.runCmd("run", RUN_SUCCEEDED)
52
53 # The stop reason of the thread should be breakpoint.
54 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
55 substrs = ['stopped',
56 'stop reason = breakpoint'])
57
58 # The breakpoint should have a hit count of 1.
59 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
60 substrs = [' resolved, hit count = 1'])
61
62 def expr(self):
63 if not self.applies():
64 return
65
66 self.common_setup()
67
68 self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"")
69
70 self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY,
71 substrs = ["int", "3"])
72
73 self.expect("expr [myObject privateMethod]", VARIABLES_DISPLAYED_CORRECTLY,
74 substrs = ["int", "5"])
75
76if __name__ == '__main__':
77 import atexit
78 lldb.SBDebugger.Initialize()
79 atexit.register(lambda: lldb.SBDebugger.Terminate())
80 unittest2.main()