blob: b552fd566a93bb2e19b43e9f5616258add8dea6b [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
Sean Callanan9df9a672015-04-03 17:17:12 +000019 @unittest2.expectedFailure("rdar://20416388")
Sean Callanan85054342015-04-03 15:39:47 +000020 def test_expr_with_dsym(self):
21 self.buildDsym()
22 self.expr()
23
24 @dwarf_test
25 @skipIfFreeBSD
26 @skipIfLinux
Sean Callanan9df9a672015-04-03 17:17:12 +000027 @unittest2.expectedFailure("rdar://20416388")
Sean Callanan85054342015-04-03 15:39:47 +000028 def test_expr_with_dwarf(self):
29 self.buildDwarf()
30 self.expr()
31
32 def setUp(self):
33 # Call super's setUp().
34 TestBase.setUp(self)
35 # Find the line number to break inside main().
36 self.line = line_number('main.m', '// Set breakpoint 0 here.')
37
38 def applies(self):
39 if platform.system() != "Darwin":
40 return False
41 if StrictVersion('12.0.0') > platform.release():
42 return False
43
44 return True
45
46 def common_setup(self):
47 exe = os.path.join(os.getcwd(), "a.out")
48 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
49
50 # Break inside the foo function which takes a bar_ptr argument.
51 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
52
53 self.runCmd("run", RUN_SUCCEEDED)
54
55 # The stop reason of the thread should be breakpoint.
56 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
57 substrs = ['stopped',
58 'stop reason = breakpoint'])
59
60 # The breakpoint should have a hit count of 1.
61 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
62 substrs = [' resolved, hit count = 1'])
63
64 def expr(self):
65 if not self.applies():
66 return
67
68 self.common_setup()
69
70 self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"")
71
72 self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY,
73 substrs = ["int", "3"])
74
75 self.expect("expr [myObject privateMethod]", VARIABLES_DISPLAYED_CORRECTLY,
76 substrs = ["int", "5"])
77
Sean Callananf0c5aeb2015-04-20 16:31:29 +000078 self.expect("expr MIN(2,3)", "#defined macro was found",
79 substrs = ["int", "2"])
80
81 self.expect("expr MAX(2,3)", "#undefd macro was correcltly not found",
82 error=True)
83
Sean Callanan85054342015-04-03 15:39:47 +000084if __name__ == '__main__':
85 import atexit
86 lldb.SBDebugger.Initialize()
87 atexit.register(lambda: lldb.SBDebugger.Terminate())
88 unittest2.main()