Skip to content

Commit 3d8c4dc

Browse files
oltolmmedismailben
authored andcommitted
[lldb] do not show misleading error when there is no frame (llvm#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. (cherry picked from commit ccbb888)
1 parent b651889 commit 3d8c4dc

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
@@ -1013,33 +1013,26 @@ bool SBFrame::GetDescription(SBStream &description) {
10131013
SBValue SBFrame::EvaluateExpression(const char *expr) {
10141014
LLDB_INSTRUMENT_VA(this, expr);
10151015

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

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

10451038
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)