199451b44SJordan Rupprecht"""Test that forward declaration of a data structure gets resolved correctly.""" 299451b44SJordan Rupprecht 399451b44SJordan Rupprecht 499451b44SJordan Rupprechtimport lldb 599451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import * 699451b44SJordan Rupprechtfrom lldbsuite.test.decorators import * 799451b44SJordan Rupprechtimport lldbsuite.test.lldbutil as lldbutil 899451b44SJordan Rupprecht 999451b44SJordan Rupprecht 1099451b44SJordan Rupprechtclass ForwardDeclarationTestCase(TestBase): 1199451b44SJordan Rupprecht def do_test(self, dictionary=None): 1299451b44SJordan Rupprecht """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" 1399451b44SJordan Rupprecht self.build(dictionary=dictionary) 1499451b44SJordan Rupprecht exe = self.getBuildArtifact("a.out") 1599451b44SJordan Rupprecht self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 1699451b44SJordan Rupprecht 1799451b44SJordan Rupprecht # Break inside the foo function which takes a bar_ptr argument. 1899451b44SJordan Rupprecht lldbutil.run_break_set_by_symbol( 19*2238dcc3SJonas Devlieghere self, "foo", num_expected_locations=1, sym_exact=True 20*2238dcc3SJonas Devlieghere ) 2199451b44SJordan Rupprecht 2299451b44SJordan Rupprecht self.runCmd("run", RUN_SUCCEEDED) 2399451b44SJordan Rupprecht 2499451b44SJordan Rupprecht # The stop reason of the thread should be breakpoint. 25*2238dcc3SJonas Devlieghere self.expect( 26*2238dcc3SJonas Devlieghere "thread list", 27*2238dcc3SJonas Devlieghere STOPPED_DUE_TO_BREAKPOINT, 28*2238dcc3SJonas Devlieghere substrs=["stopped", "stop reason = breakpoint"], 29*2238dcc3SJonas Devlieghere ) 3099451b44SJordan Rupprecht 3199451b44SJordan Rupprecht # The breakpoint should have a hit count of 1. 329f0b5f9aSSYNOPSYS\georgiev lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1) 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht # This should display correctly. 3599451b44SJordan Rupprecht # Note that the member fields of a = 1 and b = 2 is by design. 3699451b44SJordan Rupprecht self.expect( 3799451b44SJordan Rupprecht "frame variable --show-types *bar_ptr", 3899451b44SJordan Rupprecht VARIABLES_DISPLAYED_CORRECTLY, 39*2238dcc3SJonas Devlieghere substrs=["(bar) *bar_ptr = ", "(int) a = 1", "(int) b = 2"], 40*2238dcc3SJonas Devlieghere ) 4199451b44SJordan Rupprecht 4299451b44SJordan Rupprecht # And so should this. 4399451b44SJordan Rupprecht self.expect( 4499451b44SJordan Rupprecht "expression --show-types -- *bar_ptr", 4599451b44SJordan Rupprecht VARIABLES_DISPLAYED_CORRECTLY, 46*2238dcc3SJonas Devlieghere substrs=["(bar)", "(int) a = 1", "(int) b = 2"], 47*2238dcc3SJonas Devlieghere ) 4899451b44SJordan Rupprecht 4999451b44SJordan Rupprecht def test(self): 5099451b44SJordan Rupprecht self.do_test() 5199451b44SJordan Rupprecht 5299451b44SJordan Rupprecht @no_debug_info_test 5399451b44SJordan Rupprecht @skipIfDarwin 5499451b44SJordan Rupprecht @skipIf(compiler=no_match("clang")) 5559d58863SRaphael Isemann @skipIf(compiler_version=["<", "8.0"]) 5642229b6dSPavel Labath @expectedFailureAll(oslist=["windows"]) 5799451b44SJordan Rupprecht def test_debug_names(self): 5899451b44SJordan Rupprecht """Test that we are able to find complete types when using DWARF v5 5999451b44SJordan Rupprecht accelerator tables""" 6099451b44SJordan Rupprecht self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames")) 61