1"""Test variable lookup when stopped in inline functions."""
2
3
4import lldb
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class InlinesTestCase(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 inside main().
18        self.line = line_number(
19            'inlines.cpp',
20            '// Set break point at this line.')
21
22    @expectedFailureAll("llvm.org/pr26710", oslist=["linux"], compiler="gcc")
23    def test(self):
24        """Test that local variables are visible in expressions."""
25        self.build()
26        self.runToBreakpoint()
27
28        # Check that 'frame variable' finds a variable
29        self.expect(
30            "frame variable inner_input",
31            VARIABLES_DISPLAYED_CORRECTLY,
32            startstr='(int) inner_input =')
33
34        # Check that 'expr' finds a variable
35        self.expect("expr inner_input", VARIABLES_DISPLAYED_CORRECTLY,
36                    startstr='(int) $0 =')
37
38    def runToBreakpoint(self):
39        exe = self.getBuildArtifact("a.out")
40        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
41
42        # Break inside the main.
43        lldbutil.run_break_set_by_file_and_line(
44            self,
45            "inlines.cpp",
46            self.line,
47            num_expected_locations=2,
48            loc_exact=True)
49
50        self.runCmd("run", RUN_SUCCEEDED)
51
52        # The stop reason of the thread should be breakpoint.
53        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
54                    substrs=['stopped',
55                             'stop reason = breakpoint'])
56
57        # The breakpoint should have a hit count of 1.
58        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
59                    substrs=[' resolved, hit count = 1'])
60