TestForwardDeclaration.py [plain text]
"""Test that forward declaration of a data structure gets resolved correctly."""
import os, time
import unittest2
import lldb
from lldbtest import *
class ForwardDeclarationTestCase(TestBase):
mydir = os.path.join("lang", "c", "forward")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
def test_with_dsym_and_run_command(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
self.buildDsym()
self.forward_declaration()
@dwarf_test
def test_with_dwarf_and_run_command(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
self.buildDwarf()
self.forward_declaration()
def forward_declaration(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.expect("breakpoint set -n foo", BREAKPOINT_CREATED,
startstr = "Breakpoint created: 1: name = 'foo', locations = 1")
self.runCmd("run", RUN_SUCCEEDED)
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs = ['stopped',
'stop reason = breakpoint'])
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs = [' resolved, hit count = 1'])
self.expect("frame variable -T *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['(bar) *bar_ptr = ',
'(int) a = 1',
'(int) b = 2'])
self.expect("expression *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['(bar)',
'(int) a = 1',
'(int) b = 2'])
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()