Skip to content

Commit c880389

Browse files
authored
Merge pull request #10830 from swiftlang/lldb/memory-find-swift-test-to-next
[lldb][test] Add test for Swift expressions in the "memory find" command
2 parents db83ed9 + 276cb9d commit c880389

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
include Makefile.rules
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Test that running Swift expressions in the
3+
`memory find` command works.
4+
"""
5+
import lldb
6+
from lldbsuite.test.lldbtest import *
7+
from lldbsuite.test.decorators import *
8+
import lldbsuite.test.lldbutil as lldbutil
9+
10+
11+
class TestSwiftCommandMemoryFind(TestBase):
12+
def memory_find(self, name: str, expr: str, target):
13+
var = target.FindGlobalVariables(name, 1)
14+
self.assertEqual(len(var), 1)
15+
addr = var[0].AddressOf()
16+
self.assertTrue(addr)
17+
addr = addr.GetValueAsUnsigned()
18+
self.expect(f'memory find -e "{expr}" {hex(addr)} {hex(addr + 8)}',
19+
substrs=["data found at location"])
20+
21+
@swiftTest
22+
def test(self):
23+
self.build()
24+
target, _, _, _ = lldbutil.run_to_source_breakpoint(
25+
self, 'Break', lldb.SBFileSpec('main.swift'))
26+
27+
self.memory_find('elem1', 'elem1', target)
28+
self.memory_find('elem1', '130 + 7', target)
29+
30+
self.memory_find('elem2', 'elem2', target)
31+
self.memory_find('elem2', '-42', target)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let elem1: Int32 = 137
2+
let elem2: Int64 = -42
3+
print ("Break")

0 commit comments

Comments
 (0)