summaryrefslogtreecommitdiffstats
path: root/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py')
-rw-r--r--lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py b/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py
new file mode 100644
index 00000000000..c4488104d68
--- /dev/null
+++ b/lldb/test/functionalities/non-overlapping-index-variable-i/TestIndexVariable.py
@@ -0,0 +1,52 @@
+"""Test evaluating expressions which ref. index variable 'i' which just goes
+from out of scope to in scope when stopped at the breakpoint."""
+
+import unittest2
+import lldb
+from lldbtest import *
+
+class NonOverlappingIndexVariableCase(TestBase):
+
+ mydir = os.path.join("functionalities", "non-overlapping-index-variable-i")
+
+ def setUp(self):
+ TestBase.setUp(self)
+ self.source = 'main.cpp'
+ self.line_to_break = line_number(self.source, '// Set breakpoint here.')
+ self.lldb_avg = None
+ self.gdb_avg = None
+
+ def test_eval_index_variable(self):
+ """Test expressions of variable 'i' which appears in two for loops."""
+ self.buildDefault()
+ self.exe_name = 'a.out'
+ self.eval_index_variable_i(self.exe_name)
+
+ def eval_index_variable_i(self, exe_name):
+ """Test expressions of variable 'i' which appears in two for loops."""
+ self.runCmd("file %s" % exe_name, CURRENT_EXECUTABLE_SET)
+
+ self.expect('breakpoint set -f %s -l %d' % (self.source, self.line_to_break),
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+ (self.source, self.line_to_break))
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped',
+ 'stop reason = breakpoint'])
+
+ 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')
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
OpenPOWER on IntegriCloud