1"""Test that types defined in shared libraries with stripped symbols work correctly.""" 2 3 4 5import unittest2 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class SharedLibStrippedTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 @expectedFailureAll(oslist=["windows"]) 17 def test_expr(self): 18 """Test that types work when defined in a shared library and forwa/d-declared in the main executable""" 19 if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion(): 20 self.skipTest( 21 "llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef") 22 23 self.build() 24 self.common_setup() 25 26 # This should display correctly. 27 self.expect( 28 "expression --show-types -- *my_foo_ptr", 29 VARIABLES_DISPLAYED_CORRECTLY, 30 substrs=[ 31 "(foo)", 32 "(sub_foo)", 33 "other_element = 3"]) 34 35 @expectedFailureAll(oslist=["windows"]) 36 @unittest2.expectedFailure("llvm.org/PR36712") 37 def test_frame_variable(self): 38 """Test that types work when defined in a shared library and forward-declared in the main executable""" 39 self.build() 40 self.common_setup() 41 42 # This should display correctly. 43 self.expect( 44 "frame variable --show-types -- *my_foo_ptr", 45 VARIABLES_DISPLAYED_CORRECTLY, 46 substrs=[ 47 "(foo)", 48 "(sub_foo)", 49 "other_element = 3"]) 50 51 def setUp(self): 52 # Call super's setUp(). 53 TestBase.setUp(self) 54 # Find the line number to break inside main(). 55 self.source = 'main.c' 56 self.line = line_number(self.source, '// Set breakpoint 0 here.') 57 self.shlib_names = ["foo"] 58 59 def common_setup(self): 60 # Run in synchronous mode 61 self.dbg.SetAsync(False) 62 63 # Create a target by the debugger. 64 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) 65 self.assertTrue(target, VALID_TARGET) 66 67 # Break inside the foo function which takes a bar_ptr argument. 68 lldbutil.run_break_set_by_file_and_line( 69 self, self.source, self.line, num_expected_locations=1, loc_exact=True) 70 71 # Register our shared libraries for remote targets so they get 72 # automatically uploaded 73 environment = self.registerSharedLibrariesWithTarget( 74 target, self.shlib_names) 75 76 # Now launch the process, and do not stop at entry point. 77 process = target.LaunchSimple( 78 None, environment, self.get_process_working_directory()) 79 self.assertTrue(process, PROCESS_IS_VALID) 80 81 # The stop reason of the thread should be breakpoint. 82 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 83 substrs=['stopped', 84 'stop reason = breakpoint']) 85 86 # The breakpoint should have a hit count of 1. 87 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 88 substrs=[' resolved, hit count = 1']) 89