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 @skipUnlessDarwin 16 def test_frame_var_after_stop_at_interface(self): 17 """Test that we can find the implementation for an objective C type""" 18 if self.getArchitecture() == 'i386': 19 self.skipTest("requires modern objc runtime") 20 self.build() 21 self.common_setup() 22 23 line = line_number( 24 'Foo.m', '// Set breakpoint where Bar is an interface') 25 lldbutil.run_break_set_by_file_and_line( 26 self, 'Foo.m', line, num_expected_locations=1, loc_exact=True) 27 28 self.runCmd("run", RUN_SUCCEEDED) 29 30 # The stop reason of the thread should be breakpoint. 31 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 32 substrs=['stopped', 33 'stop reason = breakpoint']) 34 35 # Run and stop at Foo 36 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 37 substrs=[' resolved, hit count = 1']) 38 39 self.runCmd("continue", RUN_SUCCEEDED) 40 41 # Run at stop at main 42 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 43 substrs=[' resolved, hit count = 1']) 44 45 # This should display correctly. 46 self.expect( 47 "frame variable foo->_bar->_hidden_ivar", 48 VARIABLES_DISPLAYED_CORRECTLY, 49 substrs=[ 50 "(NSString *)", 51 "foo->_bar->_hidden_ivar = 0x"]) 52 53 @skipUnlessDarwin 54 def test_frame_var_after_stop_at_implementation(self): 55 """Test that we can find the implementation for an objective C type""" 56 if self.getArchitecture() == 'i386': 57 self.skipTest("requires modern objc runtime") 58 self.build() 59 self.common_setup() 60 61 line = line_number( 62 'Bar.m', '// Set breakpoint where Bar is an implementation') 63 lldbutil.run_break_set_by_file_and_line( 64 self, 'Bar.m', line, num_expected_locations=1, loc_exact=True) 65 66 self.runCmd("run", RUN_SUCCEEDED) 67 68 # The stop reason of the thread should be breakpoint. 69 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 70 substrs=['stopped', 71 'stop reason = breakpoint']) 72 73 # Run and stop at Foo 74 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 75 substrs=[' resolved, hit count = 1']) 76 77 self.runCmd("continue", RUN_SUCCEEDED) 78 79 # Run at stop at main 80 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 81 substrs=[' resolved, hit count = 1']) 82 83 # This should display correctly. 84 self.expect( 85 "frame variable foo->_bar->_hidden_ivar", 86 VARIABLES_DISPLAYED_CORRECTLY, 87 substrs=[ 88 "(NSString *)", 89 "foo->_bar->_hidden_ivar = 0x"]) 90 91 def common_setup(self): 92 exe = self.getBuildArtifact("a.out") 93 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 94 95 # Break inside the foo function which takes a bar_ptr argument. 96 line = line_number('main.m', '// Set breakpoint in main') 97 lldbutil.run_break_set_by_file_and_line( 98 self, "main.m", line, num_expected_locations=1, loc_exact=True) 99