[Lldb-commits] [lldb] 1b1c8e4 - [lldb] Remove CommandReturnObject's SetError(StringRef)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 23 04:25:17 PDT 2021


Author: David Spickett
Date: 2021-06-23T11:25:10Z
New Revision: 1b1c8e4a984c07a3c985408d3d80c8e24e60d3d1

URL: https://github.com/llvm/llvm-project/commit/1b1c8e4a984c07a3c985408d3d80c8e24e60d3d1
DIFF: https://github.com/llvm/llvm-project/commit/1b1c8e4a984c07a3c985408d3d80c8e24e60d3d1.diff

LOG: [lldb] Remove CommandReturnObject's SetError(StringRef)

Replacing existing uses with AppendError.

SetError is also part of the SBI API. This remains
but instead of calling the underlying SetError it
will call AppendError.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D104768

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/CommandReturnObject.h
    lldb/source/API/SBCommandReturnObject.cpp
    lldb/source/Commands/CommandObjectBreakpoint.cpp
    lldb/source/Commands/CommandObjectMultiword.cpp
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/source/Commands/CommandObjectReproducer.cpp
    lldb/source/Commands/CommandObjectThread.cpp
    lldb/source/Commands/CommandObjectTrace.cpp
    lldb/source/Commands/CommandObjectType.cpp
    lldb/source/Interpreter/CommandObject.cpp
    lldb/source/Interpreter/CommandReturnObject.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index e2b237c6d0f1c..0c995b73c4631 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -132,8 +132,6 @@ class CommandReturnObject {
 
   void SetError(const Status &error, const char *fallback_error_cstr = nullptr);
 
-  void SetError(llvm::StringRef error_cstr);
-
   lldb::ReturnStatus GetStatus();
 
   void SetStatus(lldb::ReturnStatus status);

diff  --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index 9ebdbfc6080ce..00150d198fca5 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -363,7 +363,7 @@ void SBCommandReturnObject::SetError(const char *error_cstr) {
                      error_cstr);
 
   if (error_cstr)
-    ref().SetError(error_cstr);
+    ref().AppendError(error_cstr);
 }
 
 namespace lldb_private {

diff  --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 9460ffdaa2f27..ba66a12267191 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1798,7 +1798,7 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     if (!m_name_options.m_name.OptionWasSet()) {
-      result.SetError("No name option provided.");
+      result.AppendError("No name option provided.");
       return false;
     }
 
@@ -1812,7 +1812,7 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
 
     size_t num_breakpoints = breakpoints.GetSize();
     if (num_breakpoints == 0) {
-      result.SetError("No breakpoints, cannot add names.");
+      result.AppendError("No breakpoints, cannot add names.");
       return false;
     }
 
@@ -1824,7 +1824,7 @@ class CommandObjectBreakpointNameAdd : public CommandObjectParsed {
 
     if (result.Succeeded()) {
       if (valid_bp_ids.GetSize() == 0) {
-        result.SetError("No breakpoints specified, cannot add names.");
+        result.AppendError("No breakpoints specified, cannot add names.");
         return false;
       }
       size_t num_valid_ids = valid_bp_ids.GetSize();
@@ -1883,7 +1883,7 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     if (!m_name_options.m_name.OptionWasSet()) {
-      result.SetError("No name option provided.");
+      result.AppendError("No name option provided.");
       return false;
     }
 
@@ -1897,7 +1897,7 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
 
     size_t num_breakpoints = breakpoints.GetSize();
     if (num_breakpoints == 0) {
-      result.SetError("No breakpoints, cannot delete names.");
+      result.AppendError("No breakpoints, cannot delete names.");
       return false;
     }
 
@@ -1909,7 +1909,7 @@ class CommandObjectBreakpointNameDelete : public CommandObjectParsed {
 
     if (result.Succeeded()) {
       if (valid_bp_ids.GetSize() == 0) {
-        result.SetError("No breakpoints specified, cannot delete names.");
+        result.AppendError("No breakpoints specified, cannot delete names.");
         return false;
       }
       ConstString bp_name(m_name_options.m_name.GetCurrentValue());

diff  --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 9aca787d3036d..3eafd00832446 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -396,6 +396,6 @@ bool CommandObjectProxy::Execute(const char *args_string,
   CommandObject *proxy_command = GetProxyCommandObject();
   if (proxy_command)
     return proxy_command->Execute(args_string, result);
-  result.SetError(GetUnsupportedError());
+  result.AppendError(GetUnsupportedError());
   return false;
 }

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index a0c5fc9bbf957..e4f67c04ec256 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1649,7 +1649,7 @@ class CommandObjectProcessTraceStop : public CommandObjectParsed {
     TraceSP trace_sp = process_sp->GetTarget().GetTrace();
 
     if (llvm::Error err = trace_sp->Stop())
-      result.SetError(toString(std::move(err)));
+      result.AppendError(toString(std::move(err)));
     else
       result.SetStatus(eReturnStatusSuccessFinishResult);
 

diff  --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp
index 50e24d6469aa2..01f9dc64e6f00 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -162,7 +162,8 @@ GetLoaderFromPathOrCurrent(llvm::Optional<Loader> &loader_storage,
     return loader;
 
   // This is a soft error because this is expected to fail during capture.
-  result.SetError("Not specifying a reproducer is only support during replay.");
+  result.AppendError(
+      "Not specifying a reproducer is only support during replay.");
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   return nullptr;
 }
@@ -276,7 +277,7 @@ class CommandObjectReproducerXCrash : public CommandObjectParsed {
     auto &r = Reproducer::Instance();
 
     if (!r.IsCapturing() && !r.IsReplaying()) {
-      result.SetError(
+      result.AppendError(
           "forcing a crash is only supported when capturing a reproducer.");
       result.SetStatus(eReturnStatusSuccessFinishNoResult);
       return false;
@@ -583,7 +584,7 @@ class CommandObjectReproducerDump : public CommandObjectParsed {
       return true;
     }
     case eReproducerProviderNone:
-      result.SetError("No valid provider specified.");
+      result.AppendError("No valid provider specified.");
       return false;
     }
 

diff  --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 809dce3c43558..1d31f112ae63f 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -1728,7 +1728,7 @@ class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads {
               true /* condense_trivial */, m_options.m_unreported);
           // If we didn't find a TID, stop here and return an error.
           if (!success) {
-            result.SetError("Error dumping plans:");
+            result.AppendError("Error dumping plans:");
             result.AppendError(tmp_strm.GetString());
             return false;
           }
@@ -1966,7 +1966,7 @@ class CommandObjectTraceStop : public CommandObjectMultipleThreads {
     TraceSP trace_sp = process_sp->GetTarget().GetTrace();
 
     if (llvm::Error err = trace_sp->Stop(tids))
-      result.SetError(toString(std::move(err)));
+      result.AppendError(toString(std::move(err)));
     else
       result.SetStatus(eReturnStatusSuccessFinishResult);
 
@@ -2091,7 +2091,7 @@ class CommandObjectTraceDumpInstructions
                            trace_sp->GetCursorPosition(*thread_sp)) -
                        m_consecutive_repetitions * count;
     if (position < 0)
-      result.SetError("error: no more data");
+      result.AppendError("error: no more data");
     else
       trace_sp->DumpTraceInstructions(*thread_sp, result.GetOutputStream(),
                                       count, position, m_options.m_raw);

diff  --git a/lldb/source/Commands/CommandObjectTrace.cpp b/lldb/source/Commands/CommandObjectTrace.cpp
index 21574e6357624..c55fed45d4f49 100644
--- a/lldb/source/Commands/CommandObjectTrace.cpp
+++ b/lldb/source/Commands/CommandObjectTrace.cpp
@@ -251,7 +251,7 @@ class CommandObjectTraceSchema : public CommandObjectParsed {
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     Status error;
     if (command.empty()) {
-      result.SetError(
+      result.AppendError(
           "trace schema cannot be invoked without a plug-in as argument");
       return false;
     }

diff  --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 29efe1e041996..90e224867e2a4 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2744,7 +2744,7 @@ class CommandObjectTypeLookup : public CommandObjectRaw {
   bool DoExecute(llvm::StringRef raw_command_line,
                  CommandReturnObject &result) override {
     if (raw_command_line.empty()) {
-      result.SetError(
+      result.AppendError(
           "type lookup cannot be invoked without a type name as argument");
       return false;
     }

diff  --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 51cb85f0ff9e9..5fa8468bff556 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -256,7 +256,7 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) {
   if (GetFlags().Test(eCommandProcessMustBeTraced)) {
     Target *target = m_exe_ctx.GetTargetPtr();
     if (target && !target->GetTrace()) {
-      result.SetError("Process is not being traced.");
+      result.AppendError("Process is not being traced.");
       return false;
     }
   }

diff  --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index d0d0ced2de482..85cfd9ab5cf59 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -106,12 +106,7 @@ void CommandReturnObject::AppendError(llvm::StringRef in_string) {
 void CommandReturnObject::SetError(const Status &error,
                                    const char *fallback_error_cstr) {
   assert(error.Fail() && "Expected a failed Status");
-  SetError(error.AsCString(fallback_error_cstr));
-}
-
-void CommandReturnObject::SetError(llvm::StringRef error_str) {
-  SetStatus(eReturnStatusFailed);
-  AppendError(error_str);
+  AppendError(error.AsCString(fallback_error_cstr));
 }
 
 // Similar to AppendError, but do not prepend 'Status: ' to message, and don't


        


More information about the lldb-commits mailing list