1*10b048c8SPavel Labath"""Test that forward declaration of a c++ template gets resolved correctly.""" 2*10b048c8SPavel Labath 3*10b048c8SPavel Labathimport lldb 4*10b048c8SPavel Labathfrom lldbsuite.test.lldbtest import * 5*10b048c8SPavel Labathfrom lldbsuite.test.decorators import * 6*10b048c8SPavel Labathimport lldbsuite.test.lldbutil as lldbutil 7*10b048c8SPavel Labath 8*10b048c8SPavel Labath 9*10b048c8SPavel Labathclass ForwardDeclarationTestCase(TestBase): 10*10b048c8SPavel Labath def do_test(self, dictionary=None): 11*10b048c8SPavel Labath """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" 12*10b048c8SPavel Labath self.build(dictionary=dictionary) 13*10b048c8SPavel Labath exe = self.getBuildArtifact("a.out") 14*10b048c8SPavel Labath target = self.dbg.CreateTarget(exe) 15*10b048c8SPavel Labath self.assertTrue(target, VALID_TARGET) 16*10b048c8SPavel Labath 17*10b048c8SPavel Labath environment = self.registerSharedLibrariesWithTarget(target, ["foo"]) 18*10b048c8SPavel Labath 19*10b048c8SPavel Labath # Break inside the foo function which takes a bar_ptr argument. 20*10b048c8SPavel Labath lldbutil.run_break_set_by_symbol(self, "foo", num_expected_locations=1) 21*10b048c8SPavel Labath 22*10b048c8SPavel Labath process = target.LaunchSimple( 23*10b048c8SPavel Labath None, environment, self.get_process_working_directory() 24*10b048c8SPavel Labath ) 25*10b048c8SPavel Labath self.assertTrue(process, PROCESS_IS_VALID) 26*10b048c8SPavel Labath 27*10b048c8SPavel Labath # The stop reason of the thread should be breakpoint. 28*10b048c8SPavel Labath self.expect( 29*10b048c8SPavel Labath "thread list", 30*10b048c8SPavel Labath STOPPED_DUE_TO_BREAKPOINT, 31*10b048c8SPavel Labath substrs=["stopped", "stop reason = breakpoint"], 32*10b048c8SPavel Labath ) 33*10b048c8SPavel Labath 34*10b048c8SPavel Labath # The breakpoint should have a hit count of 1. 35*10b048c8SPavel Labath lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1) 36*10b048c8SPavel Labath 37*10b048c8SPavel Labath self.expect_expr( 38*10b048c8SPavel Labath "*bar_ptr", 39*10b048c8SPavel Labath result_type="bar<int>", 40*10b048c8SPavel Labath result_children=[ValueCheck(value="47", name="a", type="int")], 41*10b048c8SPavel Labath ) 42*10b048c8SPavel Labath 43*10b048c8SPavel Labath def test(self): 44*10b048c8SPavel Labath self.do_test() 45*10b048c8SPavel Labath 46*10b048c8SPavel Labath @no_debug_info_test 47*10b048c8SPavel Labath @skipIfDarwin 48*10b048c8SPavel Labath @skipIf(compiler=no_match("clang")) 49*10b048c8SPavel Labath @skipIf(compiler_version=["<", "8.0"]) 50*10b048c8SPavel Labath @expectedFailureAll(oslist=["windows"]) 51*10b048c8SPavel Labath def test_debug_names(self): 52*10b048c8SPavel Labath """Test that we are able to find complete types when using DWARF v5 53*10b048c8SPavel Labath accelerator tables""" 54*10b048c8SPavel Labath self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames")) 55*10b048c8SPavel Labath 56*10b048c8SPavel Labath @no_debug_info_test 57*10b048c8SPavel Labath @skipIf(compiler=no_match("clang")) 58*10b048c8SPavel Labath def test_simple_template_names(self): 59*10b048c8SPavel Labath """Test that we are able to find complete types when using DWARF v5 60*10b048c8SPavel Labath accelerator tables""" 61*10b048c8SPavel Labath self.do_test(dict(CFLAGS_EXTRAS="-gsimple-template-names")) 62