diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 16fe05a400fd0..fab1ddc9e99ee 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -820,10 +820,8 @@ class CommandObjectPlatformGetFile : public CommandObjectParsed { bool DoExecute(Args &args, CommandReturnObject &result) override { // If the number of arguments is incorrect, issue an error message. if (args.GetArgumentCount() != 2) { - result.GetErrorStream().Printf("error: required arguments missing; " - "specify both the source and destination " - "file paths\n"); - result.SetStatus(eReturnStatusFailed); + result.AppendError("required arguments missing; specify both the " + "source and destination file paths"); return false; } @@ -894,10 +892,8 @@ class CommandObjectPlatformGetSize : public CommandObjectParsed { bool DoExecute(Args &args, CommandReturnObject &result) override { // If the number of arguments is incorrect, issue an error message. if (args.GetArgumentCount() != 1) { - result.GetErrorStream().Printf("error: required argument missing; " - "specify the source file path as the only " - "argument\n"); - result.SetStatus(eReturnStatusFailed); + result.AppendError("required argument missing; specify the source file " + "path as the only argument"); return false; } diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp index c8b2639344927..50e24d6469aa2 100644 --- a/lldb/source/Commands/CommandObjectReproducer.cpp +++ b/lldb/source/Commands/CommandObjectReproducer.cpp @@ -138,9 +138,7 @@ llvm::Expected static ReadFromYAML(StringRef filename) { } static void SetError(CommandReturnObject &result, Error err) { - result.GetErrorStream().Printf("error: %s\n", - toString(std::move(err)).c_str()); - result.SetStatus(eReturnStatusFailed); + result.AppendError(toString(std::move(err))); } /// Create a loader from the given path if specified. Otherwise use the current diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index e3591e713ea8e..84670707941d1 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -318,7 +318,6 @@ class CommandObjectTargetCreate : public CommandObjectParsed { if (!target_sp) { result.AppendError(error.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } @@ -342,7 +341,6 @@ class CommandObjectTargetCreate : public CommandObjectParsed { Status err = platform_sp->PutFile(file_spec, remote_file); if (err.Fail()) { result.AppendError(err.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -357,7 +355,6 @@ class CommandObjectTargetCreate : public CommandObjectParsed { Status err = platform_sp->GetFile(remote_file, file_spec); if (err.Fail()) { result.AppendError(err.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -851,9 +848,8 @@ class CommandObjectTargetVariable : public CommandObjectParsed { } if (matches == 0) { - result.GetErrorStream().Printf( - "error: can't find global variable '%s'\n", arg.c_str()); - result.SetStatus(eReturnStatusFailed); + result.AppendErrorWithFormat("can't find global variable '%s'", + arg.c_str()); return false; } else { for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) { @@ -2540,7 +2536,6 @@ class CommandObjectTargetModulesAdd : public CommandObjectParsed { else result.AppendErrorWithFormat("unsupported module: %s", entry.c_str()); - result.SetStatus(eReturnStatusFailed); return false; } else { flush = true; diff --git a/lldb/source/Commands/CommandObjectVersion.cpp b/lldb/source/Commands/CommandObjectVersion.cpp index 065cbe4660d3c..648a912601c03 100644 --- a/lldb/source/Commands/CommandObjectVersion.cpp +++ b/lldb/source/Commands/CommandObjectVersion.cpp @@ -28,7 +28,6 @@ bool CommandObjectVersion::DoExecute(Args &args, CommandReturnObject &result) { result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendError("the version command takes no arguments."); - result.SetStatus(eReturnStatusFailed); } return true; } diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index a426b382e1212..d7a446fc366c5 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -941,11 +941,11 @@ corresponding to the byte size of the data type."); } else { const char *error_cstr = error.AsCString(nullptr); if (error_cstr) - result.GetErrorStream().Printf("error: %s\n", error_cstr); + result.AppendError(error_cstr); else - result.GetErrorStream().Printf("error: unable to find any variable " - "expression path that matches '%s'\n", - command.GetArgumentAtIndex(0)); + result.AppendErrorWithFormat("unable to find any variable " + "expression path that matches '%s'", + command.GetArgumentAtIndex(0)); return false; } @@ -1065,10 +1065,8 @@ class CommandObjectWatchpointSetExpression : public CommandObjectRaw { // If no argument is present, issue an error message. There's no way to // set a watchpoint. if (raw_command.trim().empty()) { - result.GetErrorStream().Printf("error: required argument missing; " - "specify an expression to evaluate into " - "the address to watch for\n"); - result.SetStatus(eReturnStatusFailed); + result.AppendError("required argument missing; specify an expression " + "to evaluate into the address to watch for"); return false; } @@ -1095,12 +1093,10 @@ class CommandObjectWatchpointSetExpression : public CommandObjectRaw { ExpressionResults expr_result = target->EvaluateExpression(expr, frame, valobj_sp, options); if (expr_result != eExpressionCompleted) { - result.GetErrorStream().Printf( - "error: expression evaluation of address to watch failed\n"); - result.GetErrorStream() << "expression evaluated: \n" << expr << "\n"; + result.AppendError("expression evaluation of address to watch failed"); + result.AppendErrorWithFormat("expression evaluated: \n%s", expr.data()); if (valobj_sp && !valobj_sp->GetError().Success()) - result.GetErrorStream() << valobj_sp->GetError().AsCString() << "\n"; - result.SetStatus(eReturnStatusFailed); + result.AppendError(valobj_sp->GetError().AsCString()); return false; } @@ -1108,9 +1104,7 @@ class CommandObjectWatchpointSetExpression : public CommandObjectRaw { bool success = false; addr = valobj_sp->GetValueAsUnsigned(0, &success); if (!success) { - result.GetErrorStream().Printf( - "error: expression did not evaluate to an address\n"); - result.SetStatus(eReturnStatusFailed); + result.AppendError("expression did not evaluate to an address"); return false; } diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index a6fba35cb576d..51cb85f0ff9e9 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -219,7 +219,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) { // A process that is not running is considered paused. if (GetFlags().Test(eCommandProcessMustBeLaunched)) { result.AppendError("Process must exist."); - result.SetStatus(eReturnStatusFailed); return false; } } else { @@ -239,7 +238,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) { case eStateUnloaded: if (GetFlags().Test(eCommandProcessMustBeLaunched)) { result.AppendError("Process must be launched."); - result.SetStatus(eReturnStatusFailed); return false; } break; @@ -249,7 +247,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) { if (GetFlags().Test(eCommandProcessMustBePaused)) { result.AppendError("Process is running. Use 'process interrupt' to " "pause execution."); - result.SetStatus(eReturnStatusFailed); return false; } } @@ -351,7 +348,6 @@ bool CommandObject::ParseOptionsAndNotify(Args &args, Status error(group_options.NotifyOptionParsingFinished(&exe_ctx)); if (error.Fail()) { result.AppendError(error.AsCString()); - result.SetStatus(eReturnStatusFailed); return false; } return true;