[Lldb-commits] [lldb] [lldb] Test global variable support of dwim-print (NFC) (PR #157908)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 10 10:29:24 PDT 2025
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/157908
DIL has made frame variable support global variables, which in turn means dwim-print
inherits support for global variables.
>From 627df6fe1c978cf4a2fb203d4ffcc40c267bb6d3 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Wed, 10 Sep 2025 10:28:04 -0700
Subject: [PATCH] [lldb] Test global variable support of dwim-print (NFC)
DIL has made frame variable support global variables, which in turn means dwim-print
inherits support for global variables.
---
lldb/test/API/commands/dwim-print/TestDWIMPrint.py | 10 +++++++++-
lldb/test/API/commands/dwim-print/main.cpp | 3 +++
2 files changed, 12 insertions(+), 1 deletion(-)
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"); }
More information about the lldb-commits
mailing list