summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/ValueObject.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-12-08 23:13:56 +0000
committerEnrico Granata <egranata@apple.com>2014-12-08 23:13:56 +0000
commit0c10a85000074f1e8ac0fa88c853ede7b45818d4 (patch)
treedde9dd18ac5ece1dcde76e8e67638baa44d270ed /lldb/source/Core/ValueObject.cpp
parentf5b4d655d2de3fcc7b89eb33aef5a95e01aefdb9 (diff)
downloadbcm5719-llvm-0c10a85000074f1e8ac0fa88c853ede7b45818d4.tar.gz
bcm5719-llvm-0c10a85000074f1e8ac0fa88c853ede7b45818d4.zip
Add the ability for an SBValue to create a persisted version of itself.
Such a persisted version is equivalent to evaluating the value via the expression evaluator, and holding on to the $n result of the expression, except this API can be used on SBValues that do not obviously come from an expression (e.g. are the result of a memory lookup) Expose this via SBValue::Persist() in our public API layer, and ValueObject::Persist() in the lldb_private layer Includes testcase Fixes rdar://19136664 llvm-svn: 223711
Diffstat (limited to 'lldb/source/Core/ValueObject.cpp')
-rw-r--r--lldb/source/Core/ValueObject.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 1c3d1487d0c..f6d1352c407 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -37,6 +37,9 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Expression/ClangExpressionVariable.h"
+#include "lldb/Expression/ClangPersistentVariables.h"
+
#include "lldb/Host/Endian.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -4180,3 +4183,26 @@ ValueObject::CanProvideValue ()
{
return (false == GetClangType().IsAggregateType());
}
+
+ValueObjectSP
+ValueObject::Persist ()
+{
+ if (!UpdateValueIfNeeded())
+ return nullptr;
+
+ TargetSP target_sp(GetTargetSP());
+ if (!target_sp)
+ return nullptr;
+
+ ConstString name(target_sp->GetPersistentVariables().GetNextPersistentVariableName());
+
+ ClangExpressionVariableSP clang_var_sp(new ClangExpressionVariable(target_sp.get(), GetValue(), name));
+ if (clang_var_sp)
+ {
+ clang_var_sp->m_live_sp = clang_var_sp->m_frozen_sp;
+ clang_var_sp->m_flags |= ClangExpressionVariable::EVIsProgramReference;
+ target_sp->GetPersistentVariables().AddVariable(clang_var_sp);
+ }
+
+ return clang_var_sp->GetValueObject();
+}
OpenPOWER on IntegriCloud