1"""Show local variables and check that they can be inspected. 2 3This test was added after we made a change in clang to normalize 4DW_OP_constu(X < 32) to DW_OP_litX which broke the debugger because 5it didn't read the value as an unsigned. 6""" 7 8 9 10from lldbsuite.test.decorators import * 11from lldbsuite.test.lldbtest import * 12from lldbsuite.test import lldbutil 13 14 15class LocalVariablesTestCase(TestBase): 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to break inside main(). 21 self.source = 'main.c' 22 self.line = line_number( 23 self.source, '// Set break point at this line.') 24 25 @skipIfWindows 26 def test_c_local_variables(self): 27 """Test local variable value.""" 28 self.build() 29 30 # Create a target by the debugger. 31 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) 32 self.assertTrue(target, VALID_TARGET) 33 34 # Break inside the main. 35 lldbutil.run_break_set_by_file_and_line( 36 self, self.source, self.line, num_expected_locations=1, loc_exact=True) 37 38 # Now launch the process, and do not stop at entry point. 39 process = target.LaunchSimple( 40 None, None, self.get_process_working_directory()) 41 self.assertTrue(process, PROCESS_IS_VALID) 42 43 # The stop reason of the thread should be breakpoint. 44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 45 substrs=['stopped', 46 'stop reason = breakpoint']) 47 48 # The breakpoint should have a hit count of 1. 49 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 50 51 self.expect("frame variable i", VARIABLES_DISPLAYED_CORRECTLY, 52 substrs=['(unsigned int) i = 10']) 53