Skip to content

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Sep 10, 2025

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

DIL has made frame variable support global variables, which in turn means dwim-print
inherits support for global variables.
@llvmbot
Copy link
Member

llvmbot commented Sep 10, 2025

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

Changes

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 --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"); }

@kastiglione kastiglione merged commit 580fdeb into llvm:main Sep 11, 2025
11 checks passed
@kastiglione kastiglione deleted the lldb-Test-global-variable-support-of-dwim-print-NFC branch September 11, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants