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

DIL has made `frame variable` support global variables, which in turn
means dwim-print inherits support for global variables.
This commit is contained in:
Dave Lee 2025-09-11 15:55:11 -07:00 committed by GitHub
parent 50da22a9f4
commit 580fdeb6ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -16,7 +16,7 @@ class TestCase(TestBase):
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 @@ class TestCase(TestBase):
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")

View File

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