blob: cc66dd0c6ea56043aa303d11adb4f4fc335268bf [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
Zachary Turner35d017f2015-10-23 17:04:29 +00005from __future__ import print_function
6
Zachary Turner77db4a82015-10-22 20:06:20 +00007import lldb_shared
8
Jim Ingham30fadaf2014-07-08 01:07:32 +00009import lldb
10import lldbutil
11from lldbtest import *
12
13class ExprCommandCallStopContinueTestCase(TestBase):
14
15 mydir = TestBase.compute_mydir(__file__)
16
17 def setUp(self):
18 # Call super's setUp().
19 TestBase.setUp(self)
20 # Find the line number to break for main.c.
21 self.line = line_number('main.cpp',
22 '// Please test these expressions while stopped at this line:')
23 self.func_line = line_number ('main.cpp',
24 '{ 5, "five" }')
25
Vince Harron7ac3ea42015-06-26 15:13:21 +000026 @expectedFlakeyDarwin("llvm.org/pr20274")
Zachary Turner2878bf42015-08-18 20:01:28 +000027 @expectedFailureWindows("llvm.org/pr24489: Name lookup not working correctly on Windows")
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000028 def test(self):
Jim Ingham30fadaf2014-07-08 01:07:32 +000029 """Test gathering result from interrupted function call."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000030 self.build()
Jim Ingham30fadaf2014-07-08 01:07:32 +000031 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
32
33 # Some versions of GCC encode two locations for the 'return' statement in main.cpp
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("run", RUN_SUCCEEDED)
Jim Ingham30fadaf2014-07-08 01:07:32 +000037
38 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.func_line, num_expected_locations=-1, loc_exact=True)
39
40 self.expect("expr -i false -- returnsFive()", error=True,
41 substrs = ['Execution was interrupted, reason: breakpoint'])
42
43 self.runCmd("continue", "Continue completed")
44 self.expect ("thread list",
45 substrs = ['stop reason = User Expression thread plan',
46 r'Completed expression: (Five) $0 = (number = 5, name = "five")'])