TestFunctionTypes.py revision 4f995f0718299696719089084a622835b6a7b4b8
1"""Test variable with function ptr type and that break on the function works.""" 2 3import os, time 4import unittest2 5import lldb 6from lldbtest import * 7 8class TestFunctionTypes(TestBase): 9 10 mydir = "function_types" 11 12 def test_function_types(self): 13 """Test 'callback' has function ptr type, then break on the function.""" 14 exe = os.path.join(os.getcwd(), "a.out") 15 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 16 17 # Break inside the main. 18 self.expect("breakpoint set -f main.c -l 21", BREAKPOINT_CREATED, 19 startstr = "Breakpoint created: 1: file ='main.c', line = 21, locations = 1") 20 21 self.runCmd("run", RUN_STOPPED) 22 23 # The stop reason of the thread should be breakpoint. 24 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 25 substrs = ['state is Stopped', 26 'stop reason = breakpoint']) 27 28 # The breakpoint should have a hit count of 1. 29 self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, 30 substrs = [' resolved, hit count = 1']) 31 32 # Check that the 'callback' variable display properly. 33 self.expect("variable list callback", VARIABLES_DISPLAYED_CORRECTLY, 34 startstr = '(int (*)(char const *)) callback =') 35 36 # And that we can break on the callback function. 37 self.runCmd("breakpoint set -n string_not_empty", BREAKPOINT_CREATED) 38 self.runCmd("continue") 39 40 # Check that we do indeed stop on the string_not_empty function. 41 self.expect("process status", STOPPED_DUE_TO_BREAKPOINT, 42 substrs = ['where = a.out`string_not_empty', 43 'main.c:12', 44 'stop reason = breakpoint']) 45 46 47if __name__ == '__main__': 48 import atexit 49 lldb.SBDebugger.Initialize() 50 atexit.register(lambda: lldb.SBDebugger.Terminate()) 51 unittest2.main() 52