blob: 239e2de644f61bfeabd02a95f4c1f62d6c271b7b [file] [log] [blame]
Sean Callanan72e49402011-08-05 23:43:37 +00001"""
2Tests that ObjC member variables are available where they should be.
3"""
Jim Ingham63dfc722012-09-22 00:05:11 +00004import lldb
Sean Callanan72e49402011-08-05 23:43:37 +00005from lldbtest import *
Jim Ingham63dfc722012-09-22 00:05:11 +00006import lldbutil
Sean Callanan72e49402011-08-05 23:43:37 +00007
8class ObjCSelfTestCase(TestBase):
9
Greg Clayton4570d3e2013-12-10 23:19:29 +000010 mydir = TestBase.compute_mydir(__file__)
Sean Callanan72e49402011-08-05 23:43:37 +000011
Robert Flack13c7ad92015-03-30 14:12:17 +000012 @skipUnlessDarwin
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000013 def test_with_run_command(self):
Sean Callanan72e49402011-08-05 23:43:37 +000014 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000015 self.build()
Sean Callanan72e49402011-08-05 23:43:37 +000016 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
17
18 self.set_breakpoint(line_number('main.m', '// breakpoint 1'))
19 self.set_breakpoint(line_number('main.m', '// breakpoint 2'))
20
Sean Callanan05834cd2015-07-01 23:56:30 +000021 self.runCmd("process launch", RUN_SUCCEEDED)
Sean Callanan72e49402011-08-05 23:43:37 +000022
23 self.expect("expression -- m_a = 2",
24 startstr = "(int) $0 = 2")
25
26 self.runCmd("process continue")
27
28 # This would be disallowed if we enforced const. But we don't.
29 self.expect("expression -- m_a = 2",
30 error=True)
31
32 self.expect("expression -- s_a",
33 startstr = "(int) $1 = 5")
34
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000035 def set_breakpoint(self, line):
36 lldbutil.run_break_set_by_file_and_line (self, "main.m", line, num_expected_locations=1, loc_exact=True)
37
Sean Callanan72e49402011-08-05 23:43:37 +000038if __name__ == '__main__':
39 import atexit
40 lldb.SBDebugger.Initialize()
41 atexit.register(lambda: lldb.SBDebugger.Terminate())
42 unittest2.main()