diff options
author | Enrico Granata <egranata@apple.com> | 2014-12-08 23:13:56 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2014-12-08 23:13:56 +0000 |
commit | 0c10a85000074f1e8ac0fa88c853ede7b45818d4 (patch) | |
tree | dde9dd18ac5ece1dcde76e8e67638baa44d270ed /lldb/source/Core | |
parent | f5b4d655d2de3fcc7b89eb33aef5a95e01aefdb9 (diff) | |
download | bcm5719-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')
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 26 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectConstResult.cpp | 12 |
2 files changed, 34 insertions, 4 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(); +} diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index b88830f1934..fc870d72622 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -122,9 +122,10 @@ ValueObjectConstResult::Create (ExecutionContextScope *exe_scope, ValueObjectSP ValueObjectConstResult::Create (ExecutionContextScope *exe_scope, Value &value, - const ConstString &name) + const ConstString &name, + Module *module) { - return (new ValueObjectConstResult (exe_scope, value, name))->GetSP(); + return (new ValueObjectConstResult (exe_scope, value, name, module))->GetSP(); } ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope, @@ -222,15 +223,18 @@ ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope ValueObjectConstResult::ValueObjectConstResult (ExecutionContextScope *exe_scope, const Value &value, - const ConstString &name) : + const ConstString &name, + Module *module) : ValueObject (exe_scope), m_type_name (), m_byte_size (0), m_impl(this) { m_value = value; - m_value.GetData(m_data); m_name = name; + ExecutionContext exe_ctx; + exe_scope->CalculateExecutionContext(exe_ctx); + m_error = m_value.GetValueAsData(&exe_ctx, m_data, 0, module); } ValueObjectConstResult::~ValueObjectConstResult() |