diff options
author | oltolm <oleg.tolmatcev@gmail.com> | 2025-02-25 00:52:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 17:52:09 -0600 |
commit | ccbb8882ac75e73e23f31ad60588a2914ebeef04 (patch) | |
tree | 4a55a8a6c3ccf49c52ae4c97848f77d9495d4548 /lldb/source/API | |
parent | fc09550bf4982253a93088bf1668f7a917584464 (diff) | |
download | llvm-ccbb8882ac75e73e23f31ad60588a2914ebeef04.zip llvm-ccbb8882ac75e73e23f31ad60588a2914ebeef04.tar.gz llvm-ccbb8882ac75e73e23f31ad60588a2914ebeef04.tar.bz2 |
[lldb] do not show misleading error when there is no frame (#119103)
I am using VSCode with the official vscode-lldb extension. When I try to
list the breakpoints in the debug console get the message:
```
br list
can't evaluate expressions when the process is running.
```
I know that this is wrong and you need to use
```
`br list
(lldb) br list
No breakpoints currently set.
```
but the error message is misleading. I cleaned up the code and now the
error message is
```
br list
sbframe object is not valid.
```
which is still not perfect, but at least it's not misleading.
Diffstat (limited to 'lldb/source/API')
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 2300bec..5b69cf1 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -1012,33 +1012,26 @@ bool SBFrame::GetDescription(SBStream &description) { SBValue SBFrame::EvaluateExpression(const char *expr) { LLDB_INSTRUMENT_VA(this, expr); - SBValue result; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); StackFrame *frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); + SBExpressionOptions options; if (frame && target) { - SBExpressionOptions options; lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); options.SetFetchDynamicValue(fetch_dynamic_value); - options.SetUnwindOnError(true); - options.SetIgnoreBreakpoints(true); - SourceLanguage language = target->GetLanguage(); - if (!language) - language = frame->GetLanguage(); - options.SetLanguage((SBSourceLanguageName)language.name, language.version); - return EvaluateExpression(expr, options); - } else { - Status error; - error = Status::FromErrorString("can't evaluate expressions when the " - "process is running."); - ValueObjectSP error_val_sp = - ValueObjectConstResult::Create(nullptr, std::move(error)); - result.SetSP(error_val_sp, false); } - return result; + options.SetUnwindOnError(true); + options.SetIgnoreBreakpoints(true); + SourceLanguage language; + if (target) + language = target->GetLanguage(); + if (!language && frame) + language = frame->GetLanguage(); + options.SetLanguage((SBSourceLanguageName)language.name, language.version); + return EvaluateExpression(expr, options); } SBValue |