Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/command_memory_read/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS := -parse-as-library
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil


class TestCase(TestBase):
@swiftTest
def test_scalar_types(self):
self.build()
_, _, thread, _ = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
frame = thread.selected_frame

child = frame.var("name")
for t in ("String", "$sSSD"):
self.expect(
f"memory read -t {t} {child.load_addr}",
substrs=[f'(String) 0x{child.load_addr:x} = "dirk"'],
)

child = frame.var("number")
for t in ("Int", "$sSiD"):
self.expect(
f"memory read -t {t} {child.load_addr}",
substrs=[f"(Int) 0x{child.load_addr:x} = 41"],
)

child = frame.var("fact")
for t in ("Bool", "$sSbD"):
self.expect(
f"memory read -t {t} {child.load_addr}",
substrs=[f"(Bool) 0x{child.load_addr:x} = true"],
)

@swiftTest
@expectedFailureAll
def test_generic_types(self):
self.build()
_, _, thread, _ = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
frame = thread.selected_frame

child = frame.var("maybe")
for t in ("UInt64?", "$ss6UInt64VSgD"):
self.expect(
f"memory read -t {t} {child.load_addr}",
substrs=[f"(UInt64?) 0x{child.load_addr:x} = nil"],
)

child = frame.var("bytes")
for t in ("[UInt8]", "$sSays5UInt8VGD"):
self.expect(
f"memory read -t {t} {child.load_addr}",
substrs=[f"([UInt8]) 0x{child.load_addr:x} = [1, 2, 4, 8]"],
)
10 changes: 10 additions & 0 deletions lldb/test/API/lang/swift/command_memory_read/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@main enum Entry {
static func main() {
var name: String = "dirk"
var number: Int = 41
var fact: Bool = true
var maybe: UInt64? = nil
var bytes: [UInt8] = [1, 2, 4, 8]
print("break here", name, number, fact, maybe, bytes)
}
}