xref: /llvm-project/lldb/test/API/lang/objc/self/TestObjCSelf.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
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    def test_with_run_command(self):
12        """Test that the appropriate member variables are available when stopped in Objective-C class and instance methods"""
13        self.build()
14        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
15
16        self.set_breakpoint(line_number("main.m", "// breakpoint 1"))
17        self.set_breakpoint(line_number("main.m", "// breakpoint 2"))
18
19        self.runCmd("process launch", RUN_SUCCEEDED)
20
21        self.expect("expression -- m_a = 2", startstr="(int) $0 = 2")
22
23        self.runCmd("process continue")
24
25        # This would be disallowed if we enforced const.  But we don't.
26        self.expect("expression -- m_a = 2", error=True)
27
28        self.expect("expression -- s_a", startstr="(int) $1 = 5")
29
30    def set_breakpoint(self, line):
31        lldbutil.run_break_set_by_file_and_line(
32            self, "main.m", line, num_expected_locations=1, loc_exact=True
33        )
34