[Lldb-commits] [lldb] [lldb] Test global variable support of dwim-print (NFC) (PR #157908)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 10 10:29:56 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

<details>
<summary>Changes</summary>

DIL has made frame variable support global variables, which in turn means dwim-print
inherits support for global variables.


---
Full diff: https://github.com/llvm/llvm-project/pull/157908.diff


2 Files Affected:

- (modified) lldb/test/API/commands/dwim-print/TestDWIMPrint.py (+9-1) 
- (modified) lldb/test/API/commands/dwim-print/main.cpp (+3) 


``````````diff
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index 492d49f008a9e..82ff59f74f41f 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str:
         self.ci.HandleCommand(cmd, result)
         return result.GetOutput().rstrip()
 
-    VAR_IDENT = re.compile(r"(?:\$\d+|[\w.]+) = ")
+    VAR_IDENT = re.compile(r"(?:\$\d+|(?:::)?[\w.]+) = ")
 
     def _strip_result_var(self, string: str) -> str:
         """
@@ -185,3 +185,11 @@ def test_direct_child_access(self):
             self, "break inside", lldb.SBFileSpec("main.cpp")
         )
         self._expect_cmd("dwim-print number", "frame variable")
+
+    def test_global_variables(self):
+        """Test dwim-print supports global variables."""
+        self.build()
+        lldbutil.run_to_source_breakpoint(
+            self, "break here", lldb.SBFileSpec("main.cpp")
+        )
+        self._expect_cmd("dwim-print gGlobal", "frame variable")
diff --git a/lldb/test/API/commands/dwim-print/main.cpp b/lldb/test/API/commands/dwim-print/main.cpp
index d1abb5a85dd45..5b7cbd7da764b 100644
--- a/lldb/test/API/commands/dwim-print/main.cpp
+++ b/lldb/test/API/commands/dwim-print/main.cpp
@@ -1,5 +1,8 @@
 extern "C" int puts(const char *s);
 
+extern int gGlobal;
+int gGlobal = 23;
+
 struct Structure {
   int number = 30;
   void f() { puts("break inside"); }

``````````

</details>


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


More information about the lldb-commits mailing list