| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 1 | """ | 
|  | 2 | Tests that ObjC member variables are available where they should be. | 
|  | 3 | """ | 
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 4 | import lldb | 
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 5 | from lldbtest import * | 
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 6 | import lldbutil | 
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 7 |  | 
|  | 8 | class ObjCSelfTestCase(TestBase): | 
|  | 9 |  | 
|  | 10 | mydir = os.path.join("lang", "objc", "self") | 
|  | 11 |  | 
|  | 12 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 13 | @dsym_test | 
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 14 | def test_with_dsym_and_run_command(self): | 
|  | 15 | """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" | 
|  | 16 | self.buildDsym() | 
|  | 17 | self.self_commands() | 
|  | 18 |  | 
| Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 19 | @dwarf_test | 
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 20 | def test_with_dwarf_and_run_command(self): | 
|  | 21 | """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" | 
|  | 22 | self.buildDwarf() | 
|  | 23 | self.self_commands() | 
|  | 24 |  | 
|  | 25 | def setUp(self): | 
|  | 26 | TestBase.setUp(self) | 
|  | 27 |  | 
|  | 28 | def set_breakpoint(self, line): | 
| Jim Ingham | 63dfc72 | 2012-09-22 00:05:11 +0000 | [diff] [blame] | 29 | lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True) | 
| Sean Callanan | 72e4940 | 2011-08-05 23:43:37 +0000 | [diff] [blame] | 30 |  | 
|  | 31 | def self_commands(self): | 
|  | 32 | """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" | 
|  | 33 | self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) | 
|  | 34 |  | 
|  | 35 | self.set_breakpoint(line_number('main.m', '// breakpoint 1')) | 
|  | 36 | self.set_breakpoint(line_number('main.m', '// breakpoint 2')) | 
|  | 37 |  | 
|  | 38 | self.runCmd("process launch", RUN_SUCCEEDED) | 
|  | 39 |  | 
|  | 40 | self.expect("expression -- m_a = 2", | 
|  | 41 | startstr = "(int) $0 = 2") | 
|  | 42 |  | 
|  | 43 | self.runCmd("process continue") | 
|  | 44 |  | 
|  | 45 | # This would be disallowed if we enforced const.  But we don't. | 
|  | 46 | self.expect("expression -- m_a = 2", | 
|  | 47 | error=True) | 
|  | 48 |  | 
|  | 49 | self.expect("expression -- s_a", | 
|  | 50 | startstr = "(int) $1 = 5") | 
|  | 51 |  | 
|  | 52 | if __name__ == '__main__': | 
|  | 53 | import atexit | 
|  | 54 | lldb.SBDebugger.Initialize() | 
|  | 55 | atexit.register(lambda: lldb.SBDebugger.Terminate()) | 
|  | 56 | unittest2.main() |