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 mydir = TestBase.compute_mydir(__file__) 14 15 def do_test(self, dictionary=None): 16 """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" 17 self.build(dictionary=dictionary) 18 exe = self.getBuildArtifact("a.out") 19 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 20 21 # Break inside the foo function which takes a bar_ptr argument. 22 lldbutil.run_break_set_by_symbol( 23 self, "foo", num_expected_locations=1, sym_exact=True) 24 25 self.runCmd("run", RUN_SUCCEEDED) 26 27 # The stop reason of the thread should be breakpoint. 28 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 29 substrs=['stopped', 30 'stop reason = breakpoint']) 31 32 # The breakpoint should have a hit count of 1. 33 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 34 35 # This should display correctly. 36 # Note that the member fields of a = 1 and b = 2 is by design. 37 self.expect( 38 "frame variable --show-types *bar_ptr", 39 VARIABLES_DISPLAYED_CORRECTLY, 40 substrs=[ 41 '(bar) *bar_ptr = ', 42 '(int) a = 1', 43 '(int) b = 2']) 44 45 # And so should this. 46 self.expect( 47 "expression --show-types -- *bar_ptr", 48 VARIABLES_DISPLAYED_CORRECTLY, 49 substrs=[ 50 '(bar)', 51 '(int) a = 1', 52 '(int) b = 2']) 53 54 def test(self): 55 self.do_test() 56 57 @no_debug_info_test 58 @skipIfDarwin 59 @skipIf(compiler=no_match("clang")) 60 @skipIf(compiler_version=["<", "8.0"]) 61 @expectedFailureAll(oslist=["windows"]) 62 def test_debug_names(self): 63 """Test that we are able to find complete types when using DWARF v5 64 accelerator tables""" 65 self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames")) 66