xref: /llvm-project/lldb/test/API/lang/objc/ivar-IMP/TestObjCiVarIMP.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test that dynamically discovered ivars of type IMP do not crash LLDB
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class ObjCiVarIMPTestCase(TestBase):
13    @skipIf(archs=["i386"])  # objc file does not build for i386
14    @no_debug_info_test
15    def test_imp_ivar_type(self):
16        """Test that dynamically discovered ivars of type IMP do not crash LLDB"""
17        self.build()
18        exe = self.getBuildArtifact("a.out")
19
20        # Create a target from the debugger.
21        target = self.dbg.CreateTarget(exe)
22        self.assertTrue(target, VALID_TARGET)
23
24        # Set up our breakpoint
25
26        bkpt = lldbutil.run_break_set_by_source_regexp(self, "break here")
27
28        # Now launch the process, and do not stop at the entry point.
29        process = target.LaunchSimple(None, None, self.get_process_working_directory())
30
31        self.assertState(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
32
33        self.expect(
34            "frame variable --ptr-depth=1 --show-types -d run -- object",
35            substrs=["(MyClass *) object = 0x", "(void *) myImp = 0x"],
36        )
37        self.expect(
38            "disassemble --start-address `((MyClass*)object)->myImp`",
39            substrs=["-[MyClass init]"],
40        )
41