blob: a012f994b7a8135a667f1ac1a2f3c82c4ab9ef1c [file] [log] [blame]
Jim Ingham30fadaf2014-07-08 01:07:32 +00001"""
2Test calling a function, stopping in the call, continue and gather the result on stop.
3"""
4
5import unittest2
6import lldb
7import lldbutil
8from lldbtest import *
9
10class ExprCommandCallStopContinueTestCase(TestBase):
11
12 mydir = TestBase.compute_mydir(__file__)
13
14 def setUp(self):
15 # Call super's setUp().
16 TestBase.setUp(self)
17 # Find the line number to break for main.c.
18 self.line = line_number('main.cpp',
19 '// Please test these expressions while stopped at this line:')
20 self.func_line = line_number ('main.cpp',
21 '{ 5, "five" }')
22
Robert Flack13c7ad92015-03-30 14:12:17 +000023 @skipUnlessDarwin
Jim Ingham30fadaf2014-07-08 01:07:32 +000024 @dsym_test
Vince Harron7ac3ea42015-06-26 15:13:21 +000025 @expectedFlakeyDarwin("llvm.org/pr20274")
Jim Ingham30fadaf2014-07-08 01:07:32 +000026 def test_with_dsym(self):
27 """Test gathering result from interrupted function call."""
28 self.buildDsym()
29 self.call_function()
30
31 @dwarf_test
Vince Harron7ac3ea42015-06-26 15:13:21 +000032 @expectedFlakeyDarwin("llvm.org/pr20274")
Jim Ingham30fadaf2014-07-08 01:07:32 +000033 def test_with_dwarf(self):
34 """Test gathering result from interrupted function call."""
35 self.buildDwarf()
36 self.call_function()
37
38 def call_function(self):
39 """Test gathering result from interrupted function call."""
40 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
41
42 # Some versions of GCC encode two locations for the 'return' statement in main.cpp
43 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
44
Siva Chandra3154aa22015-05-27 22:27:41 +000045 self.runCmd("run", RUN_FAILED)
Jim Ingham30fadaf2014-07-08 01:07:32 +000046
47 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.func_line, num_expected_locations=-1, loc_exact=True)
48
49 self.expect("expr -i false -- returnsFive()", error=True,
50 substrs = ['Execution was interrupted, reason: breakpoint'])
51
52 self.runCmd("continue", "Continue completed")
53 self.expect ("thread list",
54 substrs = ['stop reason = User Expression thread plan',
55 r'Completed expression: (Five) $0 = (number = 5, name = "five")'])
56
57if __name__ == '__main__':
58 import atexit
59 lldb.SBDebugger.Initialize()
60 atexit.register(lambda: lldb.SBDebugger.Terminate())
61 unittest2.main()