aboutsummaryrefslogtreecommitdiff
path: root/lldb/source
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2021-06-21 15:10:46 +0000
committerDavid Spickett <david.spickett@linaro.org>2021-06-22 15:28:28 +0000
commita8dd7094d364f6fb4921627a36b920e5098e88c3 (patch)
tree729d41dcf57c3d43d723ca8a6ac1376aff19b1fd /lldb/source
parent873ff5a72864fdf60614cca8adbd0d869fc9a9a2 (diff)
downloadllvm-a8dd7094d364f6fb4921627a36b920e5098e88c3.zip
llvm-a8dd7094d364f6fb4921627a36b920e5098e88c3.tar.gz
llvm-a8dd7094d364f6fb4921627a36b920e5098e88c3.tar.bz2
[lldb] Remove more redundant SetStatus(eReturnStatusFailed)
Mostly by converting uses of GetErrorStream to AppendError, so that the call to SetStatus is implicit. Some remain where it isn't certain that you'll have a message to set, or you want the output to be on stdout. One place in CommandObjectWatchpoint previously didn't set the status to failed at all. However it's pretty obvious that it should do so. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104697
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp12
-rw-r--r--lldb/source/Commands/CommandObjectReproducer.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp9
-rw-r--r--lldb/source/Commands/CommandObjectVersion.cpp1
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp26
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp4
6 files changed, 17 insertions, 39 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 16fe05a..fab1ddc 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -820,10 +820,8 @@ public:
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 @@ public:
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 c8b2639..50e24d6 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -138,9 +138,7 @@ llvm::Expected<T> 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 e3591e7..8467070 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -318,7 +318,6 @@ protected:
if (!target_sp) {
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -342,7 +341,6 @@ protected:
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 @@ protected:
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 @@ protected:
}
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 @@ protected:
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 065cbe4..648a912 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 a426b38..d7a446f 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -941,11 +941,11 @@ protected:
} 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 @@ protected:
// 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 @@ protected:
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 @@ protected:
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 a6fba35..51cb85f 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;