[Lldb-commits] [lldb] r110992 - in /lldb/trunk/source/Commands: CommandObjectExpression.cpp CommandObjectExpression.h
Johnny Chen
johnny.chen at apple.com
Thu Aug 12 17:42:30 PDT 2010
Author: johnny
Date: Thu Aug 12 19:42:30 2010
New Revision: 110992
URL: http://llvm.org/viewvc/llvm-project?rev=110992&view=rev
Log:
Modified CommandObjectExpression::EvaluateExpression() so that it takes an
additional (ComandReturnObject *) result parameter (default to NULL) and does
the right thing in setting the result status.
Also removed used variable ast_context.
Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectExpression.h
Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=110992&r1=110991&r2=110992&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Aug 12 19:42:30 2010
@@ -189,10 +189,11 @@
}
bool
-CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream)
+CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream,
+ CommandReturnObject *result)
{
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS);
-
+
////////////////////////////////////
// Set up the target and compiler
//
@@ -251,7 +252,6 @@
bool success;
bool canInterpret = false;
- clang::ASTContext *ast_context = clang_expr.GetASTContext ();
ClangPersistentVariable *expr_result = 0;
Error expr_error;
@@ -382,21 +382,27 @@
{
StreamString ss;
- Error err = expr_result->Print (ss,
- m_exe_ctx,
- m_options.format,
- m_options.show_types,
- m_options.show_summary,
- m_options.debug);
+ Error rc = expr_result->Print (ss,
+ m_exe_ctx,
+ m_options.format,
+ m_options.show_types,
+ m_options.show_summary,
+ m_options.debug);
- if (err.Success())
- output_stream.PutCString(ss.GetString().c_str());
- else
- error_stream.Printf ("Couldn't print result : %s\n", err.AsCString("unknown error"));
+ if (rc.Fail()) {
+ error_stream.Printf ("Couldn't print result : %s\n", rc.AsCString());
+ return false;
+ }
+
+ output_stream.PutCString(ss.GetString().c_str());
+ if (result)
+ result->SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
error_stream.Printf ("Expression produced no result\n");
+ if (result)
+ result->SetStatus (eReturnStatusSuccessFinishNoResult);
}
return true;
@@ -482,7 +488,11 @@
if (expr == NULL)
expr = command;
- return EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream());
+ if (EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream(), &result))
+ return true;
+
+ result.SetStatus (eReturnStatusFailed);
+ return false;
}
lldb::OptionDefinition
Modified: lldb/trunk/source/Commands/CommandObjectExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=110992&r1=110991&r2=110992&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.h (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.h Thu Aug 12 19:42:30 2010
@@ -87,10 +87,11 @@
size_t bytes_len);
bool
- EvaluateExpression (const char *expr,
+ EvaluateExpression (const char *expr,
bool bare,
- Stream &output_stream,
- Stream &error_stream);
+ Stream &output_stream,
+ Stream &error_stream,
+ CommandReturnObject *result = NULL);
CommandOptions m_options;
ExecutionContext m_exe_ctx;
More information about the lldb-commits
mailing list