• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
34                    substrs=[' resolved, hit count = 1'])
35
36        # This should display correctly.
37        # Note that the member fields of a = 1 and b = 2 is by design.
38        self.expect(
39            "frame variable --show-types *bar_ptr",
40            VARIABLES_DISPLAYED_CORRECTLY,
41            substrs=[
42                '(bar) *bar_ptr = ',
43                '(int) a = 1',
44                '(int) b = 2'])
45
46        # And so should this.
47        self.expect(
48            "expression --show-types -- *bar_ptr",
49            VARIABLES_DISPLAYED_CORRECTLY,
50            substrs=[
51                '(bar)',
52                '(int) a = 1',
53                '(int) b = 2'])
54
55    def test(self):
56        self.do_test()
57
58    @no_debug_info_test
59    @skipIfDarwin
60    @skipIf(compiler=no_match("clang"))
61    @skipIf(compiler_version=["<", "7.0"])
62    @expectedFailureAll(oslist=["windows"])
63    def test_debug_names(self):
64        """Test that we are able to find complete types when using DWARF v5
65        accelerator tables"""
66        self.do_test(dict(CFLAGS_EXTRAS="-gdwarf-5 -gpubnames"))
67