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