================
@@ -170,6 +170,14 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
     ExpressionResults expr_result = target.EvaluateExpression(
         expr, exe_scope, valobj_sp, eval_options, &fixed_expression);
 
+    auto persistent_name = valobj_sp->GetName();
+    // EvaluateExpression doesn't generate a new persistent result (`$0`) when
+    // the expression is already just a persistent variable (`$var`). Instead,
+    // the same persistent variable is reused. Take note of when a persistent
+    // result is created, to prevent unintentional deletion of a user's
+    // persistent variable.
+    bool did_persist_result = persistent_name != expr;
----------------
kastiglione wrote:

Jim, I have updated the PR to try the expression as a persistent variable – 
prior to expression evaluation. My thinking is, instead of evaluating first, 
then asking if a persistent variable was created, it's more straight to the 
point to first ask "is this a persistent variable".

I like the idea of trying the various kinds of variables in sequence: frame, 
target, persistent.

https://github.com/llvm/llvm-project/pull/85152
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to