diff options
author | Adrian Prantl <aprantl@apple.com> | 2022-10-14 16:45:01 -0700 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2022-10-17 17:27:54 -0700 |
commit | dd5c5f72e00dca0e2458139fec09b1a715cfb238 (patch) | |
tree | cf0bdb2e7001215e5e8cc064c79b9d2db276fbe6 /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | 2c9093e649c4078c1083f489b72dda7ad54baea5 (diff) | |
download | llvm-dd5c5f72e00dca0e2458139fec09b1a715cfb238.zip llvm-dd5c5f72e00dca0e2458139fec09b1a715cfb238.tar.gz llvm-dd5c5f72e00dca0e2458139fec09b1a715cfb238.tar.bz2 |
Make sure Target::EvaluateExpression() passes up an error instead of silently dropping it.
When UserExpression::Evaluate() fails and doesn't return a ValueObject there is no vehicle for returning the error in the return value.
This behavior can be observed by applying the following patch:
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index f1a311b7252c..58c03ccdb068 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2370,6 +2370,7 @@ UserExpression *Target::GetUserExpressionForLanguage(
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options, ValueObject *ctx_obj,
Status &error) {
+ error.SetErrorStringWithFormat("Ha ha!"); return nullptr;
auto type_system_or_err = GetScratchTypeSystemForLanguage(language);
if (auto err = type_system_or_err.takeError()) {
error.SetErrorStringWithFormat(
and then running
$ lldb -o "p 1"
(lldb) p 1
(lldb)
This patch fixes this by creating an empty result ValueObject that wraps the error.
Differential Revision: https://reviews.llvm.org/D135998
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index b7d129e..be306f2 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -461,6 +461,8 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr, result.SetStatus(eReturnStatusFailed); } } + } else { + error_stream.Printf("error: unknown error\n"); } return (success != eExpressionSetupError && |