TestForwardDecl.py revision 368642381152fa240812e6a318bd0466357f6bf4
1"""Test that a forward-declared class works when its complete definition is in a library"""
2
3import os, time
4import unittest2
5import lldb
6from lldbtest import *
7
8class ForwardDeclTestCase(TestBase):
9
10    mydir = os.path.join("lang", "objc", "forward-decl")
11
12    def test_expr_with_dsym(self):
13        self.buildDsym()
14        self.expr()
15
16    def test_expr_with_dwarf(self):
17        self.buildDwarf()
18        self.expr()
19
20    def setUp(self):
21        # Call super's setUp().
22        TestBase.setUp(self)
23        # Find the line number to break inside main().
24        self.line = line_number('main.m', '// Set breakpoint 0 here.')
25
26    def common_setup(self):
27        exe = os.path.join(os.getcwd(), "a.out")
28        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
29
30        # Break inside the foo function which takes a bar_ptr argument.
31        self.expect("breakpoint set -f main.m -l %d" % self.line, BREAKPOINT_CREATED,
32            startstr = "Breakpoint created")
33
34        self.runCmd("run", RUN_SUCCEEDED)
35
36        # The stop reason of the thread should be breakpoint.
37        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
38            substrs = ['stopped',
39                       'stop reason = breakpoint'])
40
41        # The breakpoint should have a hit count of 1.
42        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
43            substrs = [' resolved, hit count = 1'])
44
45    def expr(self):
46        self.common_setup()
47
48        # This should display correctly.
49        self.expect("expression [j getMember]", VARIABLES_DISPLAYED_CORRECTLY,
50            substrs = ["= 0x"])
51
52if __name__ == '__main__':
53    import atexit
54    lldb.SBDebugger.Initialize()
55    atexit.register(lambda: lldb.SBDebugger.Terminate())
56    unittest2.main()
57