1""" 2Test calling a function, stopping in the call, continue and gather the result on stop. 3""" 4 5 6 7import lldb 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class ExprCommandCallStopContinueTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 def setUp(self): 17 # Call super's setUp(). 18 TestBase.setUp(self) 19 # Find the line number to break for main.c. 20 self.line = line_number( 21 'main.cpp', 22 '// Please test these expressions while stopped at this line:') 23 self.func_line = line_number('main.cpp', '{5, "five"}') 24 25 def test(self): 26 """Test gathering result from interrupted function call.""" 27 self.build() 28 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 29 30 # Some versions of GCC encode two locations for the 'return' statement 31 # in main.cpp 32 lldbutil.run_break_set_by_file_and_line( 33 self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True) 34 35 self.runCmd("run", RUN_SUCCEEDED) 36 37 lldbutil.run_break_set_by_file_and_line( 38 self, 39 "main.cpp", 40 self.func_line, 41 num_expected_locations=-1, 42 loc_exact=True) 43 44 self.expect("expr -i false -- returnsFive()", error=True, 45 substrs=['Execution was interrupted, reason: breakpoint']) 46 47 self.runCmd("continue", "Continue completed") 48 self.expect( 49 "thread list", 50 substrs=[ 51 'stop reason = User Expression thread plan', 52 r'Completed expression: (Five) $0 = (number = 5, name = "five")']) 53