aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Utility/ErrorMessages.h22
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp48
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp3
-rw-r--r--lldb/source/Utility/CMakeLists.txt1
-rw-r--r--lldb/source/Utility/ErrorMessages.cpp40
5 files changed, 68 insertions, 46 deletions
diff --git a/lldb/include/lldb/Utility/ErrorMessages.h b/lldb/include/lldb/Utility/ErrorMessages.h
new file mode 100644
index 0000000..116e29e
--- /dev/null
+++ b/lldb/include/lldb/Utility/ErrorMessages.h
@@ -0,0 +1,22 @@
+//===-- ErrorMessages.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_ERROR_MESSAGES_H
+#define LLDB_UTILITY_ERROR_MESSAGES_H
+
+#include "lldb/lldb-defines.h"
+#include "lldb/lldb-enumerations.h"
+#include <string>
+
+namespace lldb_private {
+
+/// Produce a human-readable rendition of an ExpressionResults value.
+std::string toString(lldb::ExpressionResults e);
+
+} // namespace lldb_private
+#endif
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index da995de..40c915b 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -48,6 +48,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/ErrorMessages.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
@@ -1817,51 +1818,8 @@ CommandInterpreter::PreprocessToken(std::string &expr_str) {
error = expr_result_valobj_sp->GetError();
if (error.Success()) {
- switch (expr_result) {
- case eExpressionSetupError:
- error.SetErrorStringWithFormat(
- "expression setup error for the expression '%s'", expr_str.c_str());
- break;
- case eExpressionParseError:
- error.SetErrorStringWithFormat(
- "expression parse error for the expression '%s'", expr_str.c_str());
- break;
- case eExpressionResultUnavailable:
- error.SetErrorStringWithFormat(
- "expression error fetching result for the expression '%s'",
- expr_str.c_str());
- break;
- case eExpressionCompleted:
- break;
- case eExpressionDiscarded:
- error.SetErrorStringWithFormat(
- "expression discarded for the expression '%s'", expr_str.c_str());
- break;
- case eExpressionInterrupted:
- error.SetErrorStringWithFormat(
- "expression interrupted for the expression '%s'", expr_str.c_str());
- break;
- case eExpressionHitBreakpoint:
- error.SetErrorStringWithFormat(
- "expression hit breakpoint for the expression '%s'",
- expr_str.c_str());
- break;
- case eExpressionTimedOut:
- error.SetErrorStringWithFormat(
- "expression timed out for the expression '%s'", expr_str.c_str());
- break;
- case eExpressionStoppedForDebug:
- error.SetErrorStringWithFormat("expression stop at entry point "
- "for debugging for the "
- "expression '%s'",
- expr_str.c_str());
- break;
- case eExpressionThreadVanished:
- error.SetErrorStringWithFormat(
- "expression thread vanished for the expression '%s'",
- expr_str.c_str());
- break;
- }
+ std::string result = lldb_private::toString(expr_result);
+ error.SetErrorString(result + "for the expression '" + expr_str + "'");
}
return error;
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 800eda9..5ff2677 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -31,6 +31,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/ErrorMessages.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
@@ -201,7 +202,7 @@ AppleObjCRuntime::GetObjectDescription(Stream &strm, Value &value,
exe_ctx, &wrapper_struct_addr, options, diagnostics, ret);
if (results != eExpressionCompleted)
return llvm::createStringError(
- "Error evaluating Print Object function: %d.\n", results);
+ "could not evaluate print object function: " + toString(results));
addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
diff --git a/lldb/source/Utility/CMakeLists.txt b/lldb/source/Utility/CMakeLists.txt
index a3b0a40..e9954d6 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -39,6 +39,7 @@ add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
DataExtractor.cpp
Diagnostics.cpp
Environment.cpp
+ ErrorMessages.cpp
Event.cpp
FileSpec.cpp
FileSpecList.cpp
diff --git a/lldb/source/Utility/ErrorMessages.cpp b/lldb/source/Utility/ErrorMessages.cpp
new file mode 100644
index 0000000..aea5cb5
--- /dev/null
+++ b/lldb/source/Utility/ErrorMessages.cpp
@@ -0,0 +1,40 @@
+//===-- ErrorMessages.cpp -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/ErrorMessages.h"
+#include "llvm/Support/ErrorHandling.h"
+
+namespace lldb_private {
+
+std::string toString(lldb::ExpressionResults e) {
+ switch (e) {
+ case lldb::eExpressionSetupError:
+ return "expression setup error";
+ case lldb::eExpressionParseError:
+ return "expression parse error";
+ case lldb::eExpressionResultUnavailable:
+ return "expression error";
+ case lldb::eExpressionCompleted:
+ return "expression completed successfully";
+ case lldb::eExpressionDiscarded:
+ return "expression discarded";
+ case lldb::eExpressionInterrupted:
+ return "expression interrupted";
+ case lldb::eExpressionHitBreakpoint:
+ return "expression hit breakpoint";
+ case lldb::eExpressionTimedOut:
+ return "expression timed out";
+ case lldb::eExpressionStoppedForDebug:
+ return "expression stop at entry point for debugging";
+ case lldb::eExpressionThreadVanished:
+ return "expression thread vanished";
+ }
+ llvm_unreachable("unhandled enumerator");
+}
+
+} // namespace lldb_private