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