Skip to content

Commit ccbb888

Browse files
authored
[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.
1 parent fc09550 commit ccbb888

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

lldb/source/API/SBFrame.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,33 +1012,26 @@ bool SBFrame::GetDescription(SBStream &description) {
10121012
SBValue SBFrame::EvaluateExpression(const char *expr) {
10131013
LLDB_INSTRUMENT_VA(this, expr);
10141014

1015-
SBValue result;
10161015
std::unique_lock<std::recursive_mutex> lock;
10171016
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
10181017

10191018
StackFrame *frame = exe_ctx.GetFramePtr();
10201019
Target *target = exe_ctx.GetTargetPtr();
1020+
SBExpressionOptions options;
10211021
if (frame && target) {
1022-
SBExpressionOptions options;
10231022
lldb::DynamicValueType fetch_dynamic_value =
10241023
frame->CalculateTarget()->GetPreferDynamicValue();
10251024
options.SetFetchDynamicValue(fetch_dynamic_value);
1026-
options.SetUnwindOnError(true);
1027-
options.SetIgnoreBreakpoints(true);
1028-
SourceLanguage language = target->GetLanguage();
1029-
if (!language)
1030-
language = frame->GetLanguage();
1031-
options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1032-
return EvaluateExpression(expr, options);
1033-
} else {
1034-
Status error;
1035-
error = Status::FromErrorString("can't evaluate expressions when the "
1036-
"process is running.");
1037-
ValueObjectSP error_val_sp =
1038-
ValueObjectConstResult::Create(nullptr, std::move(error));
1039-
result.SetSP(error_val_sp, false);
10401025
}
1041-
return result;
1026+
options.SetUnwindOnError(true);
1027+
options.SetIgnoreBreakpoints(true);
1028+
SourceLanguage language;
1029+
if (target)
1030+
language = target->GetLanguage();
1031+
if (!language && frame)
1032+
language = frame->GetLanguage();
1033+
options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1034+
return EvaluateExpression(expr, options);
10421035
}
10431036

10441037
SBValue

lldb/test/API/python_api/run_locker/TestRunLocker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,4 @@ def runlocker_test(self, stop_at_entry):
107107
"script var = lldb.frame.EvaluateExpression('SomethingToCall()'); var.GetError().GetCString()",
108108
result,
109109
)
110-
self.assertIn(
111-
"can't evaluate expressions when the process is running", result.GetOutput()
112-
)
110+
self.assertIn("sbframe object is not valid", result.GetOutput())

0 commit comments

Comments
 (0)