xref: /llvm-project/lldb/test/API/commands/expression/call-function/TestCallStopAndContinue.py (revision 8ac0aaaebbbb38d3dc863c5c5b331c8ec3238e27)
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
9
10class ExprCommandCallStopContinueTestCase(TestBase):
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(
20            self, "// break here", lldb.SBFileSpec("main.cpp")
21        )
22
23        lldbutil.run_break_set_by_file_and_line(
24            self,
25            "main.cpp",
26            line_number("main.cpp", '{5, "five"}'),
27            num_expected_locations=-1,
28            loc_exact=True,
29        )
30
31        self.expect(
32            "expr -i false -- returnsFive()",
33            error=True,
34            substrs=["Expression execution hit a breakpoint: breakpoint"],
35        )
36
37        self.runCmd("continue", "Continue completed")
38        self.expect(
39            "thread list",
40            substrs=[
41                "stop reason = User Expression thread plan",
42                r'Completed expression: (Five) $0 = (number = 5, name = "five")',
43            ],
44        )
45