1"""Test that a forward-declared class works when its complete definition is in a library""" 2 3 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class ForwardDeclTestCase(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 def setUp(self): 16 # Call super's setUp(). 17 TestBase.setUp(self) 18 # Find the line number to break inside main(). 19 self.source = 'main.m' 20 self.line = line_number(self.source, '// Set breakpoint 0 here.') 21 self.shlib_names = ["Container"] 22 23 def do_test(self, dictionary=None): 24 self.build(dictionary=dictionary) 25 26 # Create a target by the debugger. 27 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) 28 self.assertTrue(target, VALID_TARGET) 29 30 # Create the breakpoint inside function 'main'. 31 breakpoint = target.BreakpointCreateByLocation(self.source, self.line) 32 self.assertTrue(breakpoint, VALID_BREAKPOINT) 33 34 # Register our shared libraries for remote targets so they get 35 # automatically uploaded 36 environment = self.registerSharedLibrariesWithTarget( 37 target, self.shlib_names) 38 39 # Now launch the process, and do not stop at entry point. 40 process = target.LaunchSimple( 41 None, environment, self.get_process_working_directory()) 42 self.assertTrue(process, PROCESS_IS_VALID) 43 44 # The stop reason of the thread should be breakpoint. 45 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 46 substrs=['stopped', 47 'stop reason = breakpoint']) 48 49 # The breakpoint should have a hit count of 1. 50 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, 51 substrs=[' resolved, hit count = 1']) 52 53 # This should display correctly. 54 self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY, 55 substrs=["= 0x"]) 56 57 def test_expr(self): 58 self.do_test() 59 60 @no_debug_info_test 61 @skipIf(compiler=no_match("clang")) 62 @skipIf(compiler_version=["<", "7.0"]) 63 def test_debug_names(self): 64 """Test that we are able to find complete types when using DWARF v5 65 accelerator tables""" 66 self.do_test( 67 dict(CFLAGS_EXTRAS="-dwarf-version=5 -mllvm -accel-tables=Dwarf")) 68