Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 1 | """Test that DWARF types are trusted over module types""" |
| 2 | |
| 3 | import os, time |
| 4 | import unittest2 |
| 5 | import lldb |
| 6 | import platform |
| 7 | import lldbutil |
| 8 | |
| 9 | from distutils.version import StrictVersion |
| 10 | |
| 11 | from lldbtest import * |
| 12 | |
| 13 | class IncompleteModulesTestCase(TestBase): |
| 14 | |
| 15 | mydir = TestBase.compute_mydir(__file__) |
| 16 | |
Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 17 | def setUp(self): |
| 18 | # Call super's setUp(). |
| 19 | TestBase.setUp(self) |
| 20 | # Find the line number to break inside main(). |
| 21 | self.line = line_number('main.m', '// Set breakpoint 0 here.') |
| 22 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 23 | @skipUnlessDarwin |
| 24 | @unittest2.expectedFailure("rdar://20416388") |
| 25 | @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+") |
| 26 | def test_expr(self): |
| 27 | self.build() |
Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 28 | exe = os.path.join(os.getcwd(), "a.out") |
| 29 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 30 | |
| 31 | # Break inside the foo function which takes a bar_ptr argument. |
| 32 | lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True) |
| 33 | |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 34 | self.runCmd("run", RUN_SUCCEEDED) |
Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 35 | |
| 36 | # The stop reason of the thread should be breakpoint. |
| 37 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 38 | substrs = ['stopped', |
| 39 | 'stop reason = breakpoint']) |
| 40 | |
| 41 | # The breakpoint should have a hit count of 1. |
| 42 | self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, |
| 43 | substrs = [' resolved, hit count = 1']) |
| 44 | |
Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 45 | self.runCmd("settings set target.clang-module-search-paths \"" + os.getcwd() + "\"") |
| 46 | |
| 47 | self.expect("expr @import myModule; 3", VARIABLES_DISPLAYED_CORRECTLY, |
| 48 | substrs = ["int", "3"]) |
| 49 | |
| 50 | self.expect("expr [myObject privateMethod]", VARIABLES_DISPLAYED_CORRECTLY, |
| 51 | substrs = ["int", "5"]) |
| 52 | |
Sean Callanan | f0c5aeb | 2015-04-20 16:31:29 +0000 | [diff] [blame] | 53 | self.expect("expr MIN(2,3)", "#defined macro was found", |
| 54 | substrs = ["int", "2"]) |
| 55 | |
| 56 | self.expect("expr MAX(2,3)", "#undefd macro was correcltly not found", |
| 57 | error=True) |
| 58 | |
Sean Callanan | 8505434 | 2015-04-03 15:39:47 +0000 | [diff] [blame] | 59 | if __name__ == '__main__': |
| 60 | import atexit |
| 61 | lldb.SBDebugger.Initialize() |
| 62 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 63 | unittest2.main() |