================
@@ -54,47 +100,36 @@ EvaluateRequestHandler::Run(const EvaluateArguments
&arguments) const {
return body;
}
- if (arguments.context == eEvaluateContextRepl) {
- // If the expression is empty and the last expression was for a
- // variable, set the expression to the previous expression (repeat the
- // evaluation); otherwise save the current non-empty expression for the
- // next (possibly empty) variable expression.
- if (expression.empty())
- expression = dap.last_nonempty_var_expression;
- else
- dap.last_nonempty_var_expression = expression;
- }
+ // If the user expression is empty, evaluate the last valid variable
+ // expression.
+ if (expression.empty() && is_repl_context)
+ expression = dap.last_valid_variable_expression;
- // Always try to get the answer from the local variables if possible. If
- // this fails, then if the context is not "hover", actually evaluate an
- // expression using the expression parser.
- //
- // "frame variable" is more reliable than the expression parser in
- // many cases and it is faster.
- lldb::SBValue value = frame.GetValueForVariablePath(
- expression.data(), lldb::eDynamicDontRunTarget);
-
- // Freeze dry the value in case users expand it later in the debug console
- if (value.GetError().Success() && arguments.context == eEvaluateContextRepl)
- value = value.Persist();
-
- if (value.GetError().Fail() && arguments.context != eEvaluateContextHover)
- value = frame.EvaluateExpression(expression.data());
+ const bool run_as_expression = evaluate_context != eEvaluateContextHover;
+ lldb::SBValue value = EvaluateVariableExpression(
+ dap.target, frame, expression, run_as_expression);
if (value.GetError().Fail())
return ToError(value.GetError(), /*show_user=*/false);
- const bool hex = arguments.format ? arguments.format->hex : false;
+ if (is_repl_context) {
+ // save the new variable expression
+ dap.last_valid_variable_expression = expression;
+ // Freeze dry the value in case users expand it later in the debug console
+ value = value.Persist();
----------------
da-viper wrote:
We have one here
https://github.com/llvm/llvm-project/blob/2af18a17bb75a695dfb3ee8a13692222d5f789f8/lldb/test/API/tools/lldb-dap/variables/TestDAP_variables.py#L570-L585
https://github.com/llvm/llvm-project/pull/179667
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits