diff options
author | Michael Buch <michaelbuch12@gmail.com> | 2025-06-13 12:43:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-13 12:43:27 +0100 |
commit | 41b37f05554ae59974675ae219430b5598c6159f (patch) | |
tree | 6adb19b3862250ee5c7c19afa7614eb46e35ed2c /lldb/source/Commands/CommandObjectMemory.cpp | |
parent | 4236423ee863be5903819db57205fc83a4bd21e1 (diff) | |
download | llvm-41b37f05554ae59974675ae219430b5598c6159f.zip llvm-41b37f05554ae59974675ae219430b5598c6159f.tar.gz llvm-41b37f05554ae59974675ae219430b5598c6159f.tar.bz2 |
[lldb] CommandObjectMemoryFind: Improve expression evaluation error messages (#144036)
We now bubble up the expression evaluation diagnostics to the user and
also distinguish between "expression failed to parse/run" versus other
ways in which expressions didn't complete (e.g., setup errors, etc.).
Before:
```
(lldb) memory find -e "" 0x16fdfedc0 0x16fdfede0
error: expression evaluation failed. pass a string instead
(lldb) memory find -e "invalid" 0x16fdfedc0 0x16fdfede0
error: expression evaluation failed. pass a string instead
```
After:
```
(lldb) memory find -e "" 0x16fdfedc0 0x16fdfede0
error: Expression evaluation failed:
error: No result returned from expression. Exit status: 1
(lldb) memory find -e "invalid" 0x16fdfedc0 0x16fdfede0
error: Expression evaluation failed:
error: <user expression 0>:1:1: use of undeclared identifier 'invalid'
1 | invalid
| ^~~~~~~
```
Diffstat (limited to 'lldb/source/Commands/CommandObjectMemory.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index ccb06d8..5792c13 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -925,9 +925,12 @@ EvaluateExpression(llvm::StringRef expression, StackFrame &frame, ValueObjectSP result_sp; auto status = process.GetTarget().EvaluateExpression(expression, &frame, result_sp); - if (status != eExpressionCompleted || !result_sp) + if (!result_sp) return llvm::createStringError( - "expression evaluation failed. pass a string instead"); + "No result returned from expression. Exit status: %d", status); + + if (status != eExpressionCompleted) + return result_sp->GetError().ToError(); result_sp = result_sp->GetQualifiedRepresentationIfAvailable( result_sp->GetDynamicValueType(), /*synthValue=*/true); @@ -1082,6 +1085,7 @@ protected: m_memory_options.m_expr.GetValueAs<llvm::StringRef>().value_or(""), m_exe_ctx.GetFrameRef(), *process); if (!result_or_err) { + result.AppendError("Expression evaluation failed: "); result.AppendError(llvm::toString(result_or_err.takeError())); return; } |