]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/c/forward/TestForwardDeclaration.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / c / forward / TestForwardDeclaration.py
1 """Test that forward declaration of a data structure gets resolved correctly."""
2
3 from __future__ import print_function
4
5
6
7 import os, time
8 import lldb
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
11
12 class ForwardDeclarationTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def test_and_run_command(self):
17         """Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
18         self.build()
19         exe = os.path.join(os.getcwd(), "a.out")
20         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
21
22         # Break inside the foo function which takes a bar_ptr argument.
23         lldbutil.run_break_set_by_symbol (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("frame variable --show-types *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
39             substrs = ['(bar) *bar_ptr = ',
40                        '(int) a = 1',
41                        '(int) b = 2'])
42
43         # And so should this.
44         self.expect("expression --show-types -- *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
45             substrs = ['(bar)',
46                        '(int) a = 1',
47                        '(int) b = 2'])