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