1"""
2Test calling a function, stopping in the call, continue and gather the result on stop.
3"""
4
5import lldb
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9class ExprCommandCallStopContinueTestCase(TestBase):
10
11    def setUp(self):
12        # Call super's setUp().
13        TestBase.setUp(self)
14        # Find the line number to break for main.c.
15
16    def test(self):
17        """Test gathering result from interrupted function call."""
18        self.build()
19        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
20
21        lldbutil.run_break_set_by_file_and_line(
22            self,
23            "main.cpp",
24            line_number('main.cpp', '{5, "five"}'),
25            num_expected_locations=-1,
26            loc_exact=True)
27
28        self.expect("expr -i false -- returnsFive()", error=True,
29                    substrs=['Execution was interrupted, reason: breakpoint'])
30
31        self.runCmd("continue", "Continue completed")
32        self.expect(
33            "thread list",
34            substrs=[
35                'stop reason = User Expression thread plan',
36                r'Completed expression: (Five) $0 = (number = 5, name = "five")'])
37