summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-10-05 03:13:51 +0000
committerGreg Clayton <gclayton@apple.com>2010-10-05 03:13:51 +0000
commitb71f384455e299fbad5dee9582f7b59f45b6f72c (patch)
tree772de9059a3fb05301d279bd9775e7f668c298ce /lldb/source
parentdfbdfbba8f687dfc7f1745256246a92fcb64652f (diff)
downloadbcm5719-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
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBFrame.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp13
-rw-r--r--lldb/source/Core/ValueObject.cpp5
-rw-r--r--lldb/source/Core/ValueObjectConstResult.cpp10
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp13
5 files changed, 32 insertions, 13 deletions
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
OpenPOWER on IntegriCloud