blob: cb0725a952c32eb3cfa72777e3bc0d6c991c7517 [file] [log] [blame]
Sean Callanan8d285ad2013-04-30 22:05:15 +00001"""
2Tests calling a function by basename
3"""
4
5import lldb
6from lldbtest import *
7import lldbutil
8
9class CallCPPFunctionTestCase(TestBase):
10
Greg Clayton4570d3e2013-12-10 23:19:29 +000011 mydir = TestBase.compute_mydir(__file__)
Sean Callanan8d285ad2013-04-30 22:05:15 +000012
Robert Flack13c7ad92015-03-30 14:12:17 +000013 @skipUnlessDarwin
Sean Callanan8d285ad2013-04-30 22:05:15 +000014 @dsym_test
15 def test_with_dsym_and_run_command(self):
16 """Test calling a function by basename"""
17 self.buildDsym()
18 self.call_cpp_function()
19
Sean Callanan8d285ad2013-04-30 22:05:15 +000020 @dwarf_test
21 def test_with_dwarf_and_run_command(self):
22 """Test calling a function by basename"""
23 self.buildDwarf()
24 self.call_cpp_function()
25
26 def setUp(self):
27 TestBase.setUp(self)
28 self.line = line_number('main.cpp', '// breakpoint')
29
30 def call_cpp_function(self):
31 """Test calling a function by basename"""
32 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33
34 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
35
Sean Callanan05834cd2015-07-01 23:56:30 +000036 self.runCmd("process launch", RUN_SUCCEEDED)
Sean Callanan8d285ad2013-04-30 22:05:15 +000037
38 # The stop reason of the thread should be breakpoint.
39 self.expect("thread list",
40 STOPPED_DUE_TO_BREAKPOINT,
41 substrs = ['stopped', 'stop reason = breakpoint'])
42
43 self.expect("expression -- a_function_to_call()",
44 startstr = "(int) $0 = 0")
45
46if __name__ == '__main__':
47 import atexit
48 lldb.SBDebugger.Initialize()
49 atexit.register(lambda: lldb.SBDebugger.Terminate())
50 unittest2.main()