[Lldb-commits] [lldb] [lldb-dap] Add feature to remember last non-empty expression. (PR #107485)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 12 13:09:43 PDT 2024
================
@@ -1364,8 +1364,20 @@ void request_evaluate(const llvm::json::Object &request) {
std::string expression = GetString(arguments, "expression").str();
llvm::StringRef context = GetString(arguments, "context");
- if (context == "repl" && g_dap.DetectExpressionContext(frame, expression) ==
- ExpressionContext::Command) {
+ if (context == "repl" &&
+ ((!expression.empty() &&
+ g_dap.DetectExpressionContext(frame, expression) ==
+ ExpressionContext::Command) ||
+ (expression.empty() &&
+ g_dap.last_expression_context == ExpressionContext::Command))) {
+ // If the current expression is empty, and the last expression context was
+ // for a command, pass the empty expression along to the
+ // CommandInterpreter, to repeat the previous command. Also set the
+ // expression context properly for the next (possibly empty) expression.
+ g_dap.last_expression_context = ExpressionContext::Command;
+ // Since the current expression context is not for a variable, clear the
+ // last_nonempty_var_expression field.
+ g_dap.last_nonempty_var_expression.clear();
----------------
cmtice wrote:
I don't think a union will work because last_expression_context is needed and used in all empty expression cases, while for the variable case we ALSO need the last_nonempty_var_expression.
https://github.com/llvm/llvm-project/pull/107485
More information about the lldb-commits
mailing list