[Lldb-commits] [lldb] [lldb] Support Persistent Variables as DIL Identifiers (PR #215706)

Ilia Kuklin via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 26 06:17:56 PDT 2026


================
@@ -191,17 +196,26 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
     }
   }
 
-  // Second, try `expr` as a persistent variable.
+  // Case (2): Try `expr` as a persistent variable.
   if (expr.starts_with("$"))
     if (auto *state = target.GetPersistentExpressionStateForLanguage(
             language.AsLanguageType()))
-      if (auto var_sp = state->GetVariable(expr))
+      if (auto var_sp = state->GetVariable(expr)) {
         if (auto valobj_sp = var_sp->GetValueObject()) {
+
+          if (verbosity == eDWIMPrintVerbosityFull) {
+            StringRef flags;
+            if (args.HasArgs())
+              flags = args.GetArgString();
+            result.AppendNoteWithFormatv("ran `expression {0}{1}`", flags,
+                                         expr);
+          }
----------------
kuilpd wrote:

I think this note is incorrect... we don't run the `expression` command in case 2, do we? Only in case 3. This doesn't run any commands, that's why there was no note. I'm pretty sure it only handles bare persistent variables, as in 'dwim-print $0`, which can also be done by DIL in case 1. However, we still can't remove this case because DIL can be disabled in settings, reverting case 1 to using old frame var, which doesn't lookup persistent variables. I probably wouldn't change anything in this file in this PR at all, including the comments, we only add functionality to DIL.

The command `dwim-print $1->field` would be handled by the case 3, you'll need to adjust the test as well. 

https://github.com/llvm/llvm-project/pull/215706


More information about the lldb-commits mailing list