1""" 2Tests that ObjC member variables are available where they should be. 3""" 4import lldb 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9 10class ObjCSelfTestCase(TestBase): 11 12 mydir = TestBase.compute_mydir(__file__) 13 14 def test_with_run_command(self): 15 """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods""" 16 self.build() 17 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 18 19 self.set_breakpoint(line_number('main.m', '// breakpoint 1')) 20 self.set_breakpoint(line_number('main.m', '// breakpoint 2')) 21 22 self.runCmd("process launch", RUN_SUCCEEDED) 23 24 self.expect("expression -- m_a = 2", 25 startstr="(int) $0 = 2") 26 27 self.runCmd("process continue") 28 29 # This would be disallowed if we enforced const. But we don't. 30 self.expect("expression -- m_a = 2", 31 error=True) 32 33 self.expect("expression -- s_a", 34 startstr="(int) $1 = 5") 35 36 def set_breakpoint(self, line): 37 lldbutil.run_break_set_by_file_and_line( 38 self, "main.m", line, num_expected_locations=1, loc_exact=True) 39