diff options
author | Greg Clayton <gclayton@apple.com> | 2010-10-05 03:13:51 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-10-05 03:13:51 +0000 |
commit | b71f384455e299fbad5dee9582f7b59f45b6f72c (patch) | |
tree | 772de9059a3fb05301d279bd9775e7f668c298ce | |
parent | dfbdfbba8f687dfc7f1745256246a92fcb64652f (diff) | |
download | bcm5719-llvm-b71f384455e299fbad5dee9582f7b59f45b6f72c.tar.gz bcm5719-llvm-b71f384455e299fbad5dee9582f7b59f45b6f72c.zip |
Added the notion that a value object can be constant by adding:
bool ValueObject::GetIsConstant() const;
void ValueObject::SetIsConstant();
This will stop anything from being re-evaluated within the value object so
that constant result value objects can maintain their frozen values without
anything being updated or changed within the value object.
Made it so the ValueObjectConstResult can be constructed with an
lldb_private::Error object to allow for expression results to have errors.
Since ValueObject objects contain error objects, I changed the expression
evaluation in ClangUserExpression from
static Error
ClangUserExpression::Evaluate (ExecutionContext &exe_ctx,
const char *expr_cstr,
lldb::ValueObjectSP &result_valobj_sp);
to:
static lldb::ValueObjectSP
Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr);
Even though expression parsing is borked right now (pending fixes coming from
Sean Callanan), I filled in the implementation for:
SBValue SBFrame::EvaluateExpression (const char *expr);
Modified all expression code to deal with the above changes.
llvm-svn: 115589
-rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 12 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectConstResult.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Expression/ClangUserExpression.h | 6 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-forward.h | 1 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectConstResult.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Expression/ClangUserExpression.cpp | 13 |
9 files changed, 50 insertions, 17 deletions
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 592d6ab21a8..2d1b43a0a6f 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -201,6 +201,18 @@ public: bool use_objc, bool scope_already_checked); + bool + GetIsConstant () const + { + return m_update_id == LLDB_INVALID_UID; + } + + void + SetIsConstant () + { + m_update_id = LLDB_INVALID_UID; + } + protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index c1e82920f72..f1e1c3ebcde 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -32,6 +32,9 @@ public: uint8_t addr_size); + // When an expression fails to evaluate, we return an error + ValueObjectConstResult (const Error& error); + virtual ~ValueObjectConstResult(); virtual size_t diff --git a/lldb/include/lldb/Expression/ClangUserExpression.h b/lldb/include/lldb/Expression/ClangUserExpression.h index ab97f107264..f193446b8a8 100644 --- a/lldb/include/lldb/Expression/ClangUserExpression.h +++ b/lldb/include/lldb/Expression/ClangUserExpression.h @@ -172,10 +172,8 @@ public: } - static Error - Evaluate (ExecutionContext &exe_ctx, - const char *expr_cstr, - lldb::ValueObjectSP &result_valobj_sp); + static lldb::ValueObjectSP + Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr); private: //------------------------------------------------------------------ diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 82b45215caa..61137098ab8 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -43,6 +43,7 @@ class CPPLanguageRuntime; class ClangASTContext; class ClangExpression; class ClangExpressionDeclMap; +class ClangExpressionVariable; class ClangExpressionVariableList; class ClangExpressionVariableStore; class CommandInterpreter; diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 0b2db3328dd..9ca92fc9b6b 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -20,6 +20,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Expression/ClangUserExpression.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/VariableList.h" @@ -416,6 +417,9 @@ SBFrame::EvaluateExpression (const char *expr) lldb::SBValue expr_result_value; if (m_opaque_sp) { + ExecutionContext exe_ctx; + m_opaque_sp->CalculateExecutionContext (exe_ctx); + *expr_result_value = ClangUserExpression::Evaluate (exe_ctx, expr); } return expr_result_value; } diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index a02451ceb46..1f6c3de1903 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -233,13 +233,10 @@ CommandObjectExpression::EvaluateExpression m_exe_ctx.process->SetDynamicCheckers(dynamic_checkers); } - lldb::ValueObjectSP result_valobj_sp; - - Error expr_error (ClangUserExpression::Evaluate (m_exe_ctx, expr, result_valobj_sp)); - - if (expr_error.Success()) + lldb::ValueObjectSP result_valobj_sp (ClangUserExpression::Evaluate (m_exe_ctx, expr)); + assert (result_valobj_sp.get()); + if (result_valobj_sp->GetError().Success()) { - assert (result_valobj_sp.get() != NULL); ValueObject::DumpValueObject (output_stream, m_exe_ctx.GetBestExecutionContextScope(), result_valobj_sp.get(), // Variable object to dump @@ -257,9 +254,9 @@ CommandObjectExpression::EvaluateExpression } else { - error_stream.PutCString(expr_error.AsCString()); + error_stream.PutCString(result_valobj_sp->GetError().AsCString()); if (result) - result->SetStatus (eReturnStatusSuccessFinishNoResult); + result->SetStatus (eReturnStatusFailed); } return true; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 4b7f0d70807..cc7f40887b8 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -79,6 +79,11 @@ ValueObject::GetUpdateID() const bool ValueObject::UpdateValueIfNeeded (ExecutionContextScope *exe_scope) { + // If this is a constant value, then our success is predicated on whether + // we have an error or not + if (GetIsConstant()) + return m_error.Success(); + if (exe_scope) { Process *process = exe_scope->CalculateProcess(); diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index d2317dfde41..103edadddbe 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -46,6 +46,16 @@ ValueObjectConstResult::ValueObjectConstResult m_value.SetValueType(Value::eValueTypeHostAddress); m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type); m_name = name; + SetIsConstant (); +} + +ValueObjectConstResult::ValueObjectConstResult (const Error& error) : + ValueObject (), + m_clang_ast (NULL), + m_type_name () +{ + m_error = error; + SetIsConstant (); } ValueObjectConstResult::~ValueObjectConstResult() diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp index ed50ea0d0a1..888a2666679 100644 --- a/lldb/source/Expression/ClangUserExpression.cpp +++ b/lldb/source/Expression/ClangUserExpression.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionParser.h" #include "lldb/Expression/ClangFunction.h" @@ -338,12 +339,11 @@ ClangUserExpression::DwarfOpcodeStream () } -Error -ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, lldb::ValueObjectSP &result_valobj_sp) +lldb::ValueObjectSP +ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr) { Error error; - result_valobj_sp.reset(); - + lldb::ValueObjectSP result_valobj_sp; ClangUserExpression user_expression (expr_cstr); StreamString error_stream; @@ -385,6 +385,9 @@ ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, } } } - return error; + if (result_valobj_sp.get() == NULL) + result_valobj_sp.reset (new ValueObjectConstResult (error)); + + return result_valobj_sp; }
\ No newline at end of file |