[Lldb-commits] [lldb] efc5236 - [lldb] Improve error reporting in ScriptedInterface

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 3 19:33:25 PST 2023


Author: Med Ismail Bennani
Date: 2023-03-03T19:33:02-08:00
New Revision: efc52361ddb7282825f1f813553f322bd119b830

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

LOG: [lldb] Improve error reporting in ScriptedInterface

This patch improve error reporting in the Scripted Interface.

Previously, it would only log the content of the Status object and
overwrite it with the error_msg function parameter.

This patch changes that to append the Status object content to the
`error_msg` string.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

Added: 
    

Modified: 
    lldb/include/lldb/Interpreter/ScriptedInterface.h

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/ScriptedInterface.h b/lldb/include/lldb/Interpreter/ScriptedInterface.h
index 31064de7b765..10a9f418df80 100644
--- a/lldb/include/lldb/Interpreter/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/ScriptedInterface.h
@@ -40,9 +40,12 @@ class ScriptedInterface {
                               LLDBLog log_caterogy = LLDBLog::Process) {
     LLDB_LOGF(GetLog(log_caterogy), "%s ERROR = %s", caller_name.data(),
               error_msg.data());
-    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
-                                     llvm::Twine(error_msg))
-                             .str());
+    llvm::Twine err = llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
+                                  llvm::Twine(error_msg));
+    if (const char *detailed_error = error.AsCString())
+      err.concat(llvm::Twine(" (") + llvm::Twine(detailed_error) +
+                 llvm::Twine(")"));
+    error.SetErrorString(err.str());
     return {};
   }
 


        


More information about the lldb-commits mailing list