1"""Test evaluating expressions which ref. index variable 'i' which just goes 2from out of scope to in scope when stopped at the breakpoint.""" 3 4 5 6import lldb 7from lldbsuite.test.lldbtest import * 8import lldbsuite.test.lldbutil as lldbutil 9 10 11class NonOverlappingIndexVariableCase(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 def setUp(self): 16 TestBase.setUp(self) 17 self.source = 'main.cpp' 18 self.line_to_break = line_number( 19 self.source, '// Set breakpoint here.') 20 21 # rdar://problem/9890530 22 def test_eval_index_variable(self): 23 """Test expressions of variable 'i' which appears in two for loops.""" 24 self.build() 25 self.runCmd("file " + self.getBuildArtifact("a.out"), 26 CURRENT_EXECUTABLE_SET) 27 28 lldbutil.run_break_set_by_file_and_line( 29 self, 30 self.source, 31 self.line_to_break, 32 num_expected_locations=1, 33 loc_exact=True) 34 35 self.runCmd("run", RUN_SUCCEEDED) 36 37 # The stop reason of the thread should be breakpoint. 38 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 39 substrs=['stopped', 40 'stop reason = breakpoint']) 41 42 self.runCmd('frame variable i') 43 self.runCmd('expr i') 44 self.runCmd('expr ptr[0]->point.x') 45 self.runCmd('expr ptr[0]->point.y') 46 self.runCmd('expr ptr[i]->point.x') 47 self.runCmd('expr ptr[i]->point.y') 48