2011-08-03 01:34:29 +00:00
|
|
|
"""Test evaluating expressions which ref. index variable 'i' which just goes
|
|
|
|
from out of scope to in scope when stopped at the breakpoint."""
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2011-08-03 01:34:29 +00:00
|
|
|
import lldb
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
|
|
|
import lldbsuite.test.lldbutil as lldbutil
|
2011-08-03 01:34:29 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-08-03 01:34:29 +00:00
|
|
|
class NonOverlappingIndexVariableCase(TestBase):
|
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2011-08-03 01:34:29 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
TestBase.setUp(self)
|
|
|
|
self.source = 'main.cpp'
|
2016-09-06 20:57:50 +00:00
|
|
|
self.line_to_break = line_number(
|
|
|
|
self.source, '// Set breakpoint here.')
|
2011-08-03 01:34:29 +00:00
|
|
|
|
2011-08-03 18:35:48 +00:00
|
|
|
# rdar://problem/9890530
|
2011-08-03 01:34:29 +00:00
|
|
|
def test_eval_index_variable(self):
|
|
|
|
"""Test expressions of variable 'i' which appears in two for loops."""
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build()
|
2018-01-19 23:24:35 +00:00
|
|
|
self.runCmd("file " + self.getBuildArtifact("a.out"),
|
|
|
|
CURRENT_EXECUTABLE_SET)
|
2011-08-03 01:34:29 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldbutil.run_break_set_by_file_and_line(
|
|
|
|
self,
|
|
|
|
self.source,
|
|
|
|
self.line_to_break,
|
|
|
|
num_expected_locations=1,
|
|
|
|
loc_exact=True)
|
2011-08-03 01:34:29 +00:00
|
|
|
|
2015-07-01 23:56:30 +00:00
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
2011-08-03 01:34:29 +00:00
|
|
|
|
|
|
|
# The stop reason of the thread should be breakpoint.
|
|
|
|
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
2016-09-06 20:57:50 +00:00
|
|
|
substrs=['stopped',
|
|
|
|
'stop reason = breakpoint'])
|
2011-08-03 01:34:29 +00:00
|
|
|
|
|
|
|
self.runCmd('frame variable i')
|
|
|
|
self.runCmd('expr i')
|
|
|
|
self.runCmd('expr ptr[0]->point.x')
|
|
|
|
self.runCmd('expr ptr[0]->point.y')
|
|
|
|
self.runCmd('expr ptr[i]->point.x')
|
|
|
|
self.runCmd('expr ptr[i]->point.y')
|