1"""Check that compiler-generated constant values work correctly"""
2
3
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11class ConstVariableTestCase(TestBase):
12
13    mydir = TestBase.compute_mydir(__file__)
14
15    @expectedFailureAll(oslist=["freebsd", "linux"], compiler="icc")
16    @expectedFailureAll(archs=['mips', 'mipsel', 'mips64', 'mips64el'])
17    @expectedFailureAll(
18        oslist=["windows"],
19        bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
20    def test_and_run_command(self):
21        """Test interpreted and JITted expressions on constant values."""
22        self.build()
23        exe = self.getBuildArtifact("a.out")
24        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
25
26        # Break inside the main.
27        lldbutil.run_break_set_by_symbol(
28            self, "main", num_expected_locations=1)
29
30        self.runCmd("run", RUN_SUCCEEDED)
31
32        # The stop reason of the thread should be breakpoint.
33        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
34                    substrs=['stopped',
35                             'stop reason = breakpoint'])
36
37        # The breakpoint should have a hit count of 1.
38        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
39                    substrs=[' resolved, hit count = 1'])
40
41        self.runCmd("next")
42        self.runCmd("next")
43
44        # Try frame variable.
45        self.expect("frame variable index", VARIABLES_DISPLAYED_CORRECTLY,
46                    substrs=['(int32_t) index = 512'])
47
48        # Try an interpreted expression.
49        self.expect("expr (index + 512)", VARIABLES_DISPLAYED_CORRECTLY,
50                    substrs=['1024'])
51
52        # Try a JITted expression.
53        self.expect(
54            "expr (int)getpid(); (index - 256)",
55            VARIABLES_DISPLAYED_CORRECTLY,
56            substrs=['256'])
57
58        self.runCmd("kill")
59