[Lldb-commits] [lldb] [lldb] Support Persistent Variables as DIL Identifiers (PR #215706)
Will Hawkins via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 26 07:04:05 PDT 2026
================
@@ -0,0 +1,119 @@
+"""
+Make sure accessing persistent/result variables works using DIL parser/evaluator.
+"""
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test import lldbutil
+
+
+class TestFrameVarDILPersistentResultVariableLookup(TestBase):
+ # If your test case doesn't stress debug info, then
+ # set this to true. That way it won't be run once for
+ # each debug info format.
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_frame_var(self):
+ self.build()
+ _, process, _, _ = lldbutil.run_to_source_breakpoint(
+ self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+ )
+
+ self.runCmd("settings set target.experimental.use-DIL true")
+
+ # Establish persistent variables.
+
+ # Establish a persistent variable with integer type.
+ self.expect(
+ "dwim-print --persistent-result true -- foo + 5", startstr="(int) $0 = "
+ )
+ # Establish a persistent variable using dwim-print with derived type (using C specification terminology).
+ self.expect(
+ "dwim-print --persistent-result true -- hsmt",
+ startstr="(HasMembersT) $1 = ",
+ )
+ # Establish a persistent variable using dwim-print as pointer to variable
+ # with derived type (using C specification terminology).
+ self.expect(
+ "dwim-print --persistent-result true -- &hsmt",
+ startstr="(HasMembersT *) $2 = ",
+ )
+ # Establish result variable using expression.
+ self.expect(
+ "expression foo",
+ startstr="(int) $3 = 1",
+ )
+ # Establish result variables with user-defined names.
+ self.runCmd(
+ "expression int *$foop = &foo",
+ )
+ self.runCmd(
+ "expression HasMembersT *$hsmtp = &hsmt",
+ )
+
+ # Test that accessing those persistent/result variables yields the proper values.
+
+ # Check to make sure that `dwim-print`'s note indicates the proper path through the code was taken.
+ self.runCmd("settings set dwim-print-verbosity full")
+ # Case (1) checks (see lldb/source/Commands/CommandObjectDWIMPrint.cpp).
+ self.expect("dwim-print $0", startstr="note: ran `frame variable $0`")
+ self.expect(
+ "dwim-print $1.doublem", startstr="note: ran `frame variable $1.doublem`"
+ )
+ # Case (2) check (see lldb/source/Commands/CommandObjectDWIMPrint.cpp).
+ self.expect(
+ "dwim-print $2->doublem", startstr="note: ran `expression $2->doublem`"
----------------
hawkinsw wrote:
@kuilpd I am having trouble squaring this test case and the output that it produces with your comment above.
https://github.com/llvm/llvm-project/pull/215706
More information about the lldb-commits
mailing list