xref: /llvm-project/lldb/test/API/lang/objc/conflicting-definition/TestConflictingDefinition.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""Test that types defined in shared libraries work correctly."""
2
3
4import lldb
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class TestRealDefinition(TestBase):
11    def test_frame_var_after_stop_at_implementation(self):
12        """Test that we can find the implementation for an objective C type"""
13        if self.getArchitecture() == "i386":
14            self.skipTest("requires modern objc runtime")
15        self.build()
16        self.shlib_names = ["libTestExt.dylib", "libTest.dylib"]
17        self.common_setup()
18
19        line = line_number("TestExt/TestExt.m", "// break here")
20        lldbutil.run_break_set_by_file_and_line(
21            self, "TestExt.m", line, num_expected_locations=1, loc_exact=True
22        )
23
24        self.runCmd("run", RUN_SUCCEEDED)
25
26        # The stop reason of the thread should be breakpoint.
27        self.expect(
28            "thread list",
29            STOPPED_DUE_TO_BREAKPOINT,
30            substrs=["stopped", "stop reason = breakpoint"],
31        )
32
33        lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
34
35        # This should display correctly.
36        self.expect(
37            "expr 42", "A simple expression should execute correctly", substrs=["42"]
38        )
39
40    def common_setup(self):
41        exe = self.getBuildArtifact("a.out")
42        target = self.dbg.CreateTarget(exe)
43        self.registerSharedLibrariesWithTarget(target, self.shlib_names)
44
45        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
46