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