Files
clang-p2996/lldb/test/expression_command/persistent_variables/TestPersistentVariables.py
Sean Callanan fbf5c682cb Fixed a bug where persistent variables did not
live as long as they needed to.  This led to
equality tests involving persistent variables
often failing or succeeding when they had no
business doing so.

To do this, I introduced the ability for a
memory allocation to "leak" - that is, to
persist in the process beyond the lifetime of
the expression.  Hand-declared persistent
variables do this now.

<rdar://problem/13956311>

llvm-svn: 182528
2013-05-22 22:49:06 +00:00

55 lines
1.3 KiB
Python

"""
Test that lldb persistent variables works correctly.
"""
import os, time
import unittest2
import lldb
from lldbtest import *
class PersistentVariablesTestCase(TestBase):
mydir = os.path.join("expression_command", "persistent_variables")
def test_persistent_variables(self):
"""Test that lldb persistent variables works correctly."""
self.buildDefault()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
self.runCmd("breakpoint set --source-pattern-regexp break")
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("expression int $i = i")
self.expect("expression $i == i",
startstr = "(bool) $0 = true")
self.expect("expression $i + 1",
startstr = "(int) $1 = 6")
# (int) $0 = 6
self.expect("expression $i + 3",
startstr = "(int) $2 = 8")
# (int) $1 = 8
self.expect("expression $2 + $1",
startstr = "(int) $3 = 14")
# (int) $2 = 14
self.expect("expression $3",
startstr = "(int) $3 = 14")
# (int) $2 = 14
self.expect("expression $2",
startstr = "(int) $2 = 8")
# (int) $1 = 8
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()