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    def test_frame_var_after_stop_at_interface(self):
14        """Test that we can find the implementation for an objective C type"""
15        if self.getArchitecture() == 'i386':
16            self.skipTest("requires modern objc runtime")
17        self.build()
18
19        lldbutil.run_to_source_breakpoint(
20            self,
21            '// Set breakpoint where Bar is an interface',
22            lldb.SBFileSpec("Foo.m", False))
23
24        # Break inside the foo function which takes a bar_ptr argument.
25        self.expect('breakpoint set -p "// Set breakpoint in main"')
26        self.runCmd("continue", RUN_SUCCEEDED)
27
28        # Run at stop at main
29        lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
30
31        # This should display correctly.
32        self.expect(
33            "frame variable foo->_bar->_hidden_ivar",
34            VARIABLES_DISPLAYED_CORRECTLY,
35            substrs=[
36                "(NSString *)",
37                "foo->_bar->_hidden_ivar = 0x"])
38
39    def test_frame_var_after_stop_at_implementation(self):
40        """Test that we can find the implementation for an objective C type"""
41        if self.getArchitecture() == 'i386':
42            self.skipTest("requires modern objc runtime")
43        self.build()
44
45        lldbutil.run_to_source_breakpoint(
46            self,
47            '// Set breakpoint where Bar is an implementation',
48            lldb.SBFileSpec("Bar.m", False))
49
50        self.expect('breakpoint set -p "// Set breakpoint in main"')
51        self.runCmd("continue", RUN_SUCCEEDED)
52
53        # Run at stop at main
54        lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1)
55
56        # This should display correctly.
57        self.expect(
58            "frame variable foo->_bar->_hidden_ivar",
59            VARIABLES_DISPLAYED_CORRECTLY,
60            substrs=[
61                "(NSString *)",
62                "foo->_bar->_hidden_ivar = 0x"])
63