diff --git a/lldb/test/API/lang/swift/command_memory_find/Makefile b/lldb/test/API/lang/swift/command_memory_find/Makefile new file mode 100644 index 0000000000000..2a69023633b34 --- /dev/null +++ b/lldb/test/API/lang/swift/command_memory_find/Makefile @@ -0,0 +1,3 @@ +SWIFT_SOURCES := main.swift + +include Makefile.rules diff --git a/lldb/test/API/lang/swift/command_memory_find/TestSwiftCommandMemoryFind.py b/lldb/test/API/lang/swift/command_memory_find/TestSwiftCommandMemoryFind.py new file mode 100644 index 0000000000000..0259e1a05d477 --- /dev/null +++ b/lldb/test/API/lang/swift/command_memory_find/TestSwiftCommandMemoryFind.py @@ -0,0 +1,31 @@ +""" +Test that running Swift expressions in the +`memory find` command works. +""" +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil + + +class TestSwiftCommandMemoryFind(TestBase): + def memory_find(self, name: str, expr: str, target): + var = target.FindGlobalVariables(name, 1) + self.assertEqual(len(var), 1) + addr = var[0].AddressOf() + self.assertTrue(addr) + addr = addr.GetValueAsUnsigned() + self.expect(f'memory find -e "{expr}" {hex(addr)} {hex(addr + 8)}', + substrs=["data found at location"]) + + @swiftTest + def test(self): + self.build() + target, _, _, _ = lldbutil.run_to_source_breakpoint( + self, 'Break', lldb.SBFileSpec('main.swift')) + + self.memory_find('elem1', 'elem1', target) + self.memory_find('elem1', '130 + 7', target) + + self.memory_find('elem2', 'elem2', target) + self.memory_find('elem2', '-42', target) diff --git a/lldb/test/API/lang/swift/command_memory_find/main.swift b/lldb/test/API/lang/swift/command_memory_find/main.swift new file mode 100644 index 0000000000000..3de3d3615d45c --- /dev/null +++ b/lldb/test/API/lang/swift/command_memory_find/main.swift @@ -0,0 +1,3 @@ +let elem1: Int32 = 137 +let elem2: Int64 = -42 +print ("Break")