Jim Ingham | 30fadaf | 2014-07-08 01:07:32 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test calling a function, stopping in the call, continue and gather the result on stop. |
| 3 | """ |
| 4 | |
| 5 | import unittest2 |
| 6 | import lldb |
| 7 | import lldbutil |
| 8 | from lldbtest import * |
| 9 | |
| 10 | class 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 Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 23 | @skipUnlessDarwin |
Jim Ingham | 30fadaf | 2014-07-08 01:07:32 +0000 | [diff] [blame] | 24 | @dsym_test |
Vince Harron | 7ac3ea4 | 2015-06-26 15:13:21 +0000 | [diff] [blame^] | 25 | @expectedFlakeyDarwin("llvm.org/pr20274") |
Jim Ingham | 30fadaf | 2014-07-08 01:07:32 +0000 | [diff] [blame] | 26 | 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 Harron | 7ac3ea4 | 2015-06-26 15:13:21 +0000 | [diff] [blame^] | 32 | @expectedFlakeyDarwin("llvm.org/pr20274") |
Jim Ingham | 30fadaf | 2014-07-08 01:07:32 +0000 | [diff] [blame] | 33 | 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 Chandra | 3154aa2 | 2015-05-27 22:27:41 +0000 | [diff] [blame] | 45 | self.runCmd("run", RUN_FAILED) |
Jim Ingham | 30fadaf | 2014-07-08 01:07:32 +0000 | [diff] [blame] | 46 | |
| 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 | |
| 57 | if __name__ == '__main__': |
| 58 | import atexit |
| 59 | lldb.SBDebugger.Initialize() |
| 60 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 61 | unittest2.main() |