1"""Test that forward declaration of a data structure gets resolved correctly.""" 2 3 4 5import lldb 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test.decorators import * 8import lldbsuite.test.lldbutil as lldbutil 9 10 11class ForwardDeclarationTestCase(TestBase): 12 13 def do_test(self, dictionary=None): 14 """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" 15 self.build(dictionary=dictionary) 16 exe = self.getBuildArtifact("a.out") 17 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 18 19 # Break inside the foo function which takes a bar_ptr argument. 20 lldbutil.run_break_set_by_symbol( 21 self, "foo", num_expected_locations=1, sym_exact=True) 22 23 self.runCmd("run", RUN_SUCCEEDED) 24 25 # The stop reason of the thread should be breakpoint. 26 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 27 substrs=['stopped', 28 'stop reason = breakpoint']) 29 30 # The breakpoint should have a hit count of 1. 31 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 32 33 # This should display correctly. 34 # Note that the member fields of a = 1 and b = 2 is by design. 35 self.expect( 36 "frame variable --show-types *bar_ptr", 37 VARIABLES_DISPLAYED_CORRECTLY, 38 substrs=[ 39 '(bar) *bar_ptr = ', 40 '(int) a = 1', 41 '(int) b = 2']) 42 43 # And so should this. 44 self.expect( 45 "expression --show-types -- *bar_ptr", 46 VARIABLES_DISPLAYED_CORRECTLY, 47 substrs=[ 48 '(bar)', 49 '(int) a = 1', 50 '(int) b = 2']) 51 52 def test(self): 53 self.do_test() 54 55 @no_debug_info_test 56 @skipIfDarwin 57 @skipIf(compiler=no_match("clang")) 58 @skipIf(compiler_version=["<", "8.0"]) 59 @expectedFailureAll(oslist=["windows"]) 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(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames")) 64