Skip to content

Commit 10f3828

Browse files
authored
Merge pull request #41544 from compnerd/blind-cross
swift-inspect: more typo/correctness fixes
2 parents a5a15ba + 21edf9c commit 10f3828

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tools/swift-inspect/Sources/swift-inspect/DarwinRemoteProcess.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ extension DarwinRemoteProcess {
151151
UnsafeMutableRawPointer(mutating: $0),
152152
CUnsignedInt(MALLOC_PTR_IN_USE_RANGE_TYPE),
153153
{ (task, context, type, ranges, count) in
154+
let callback: (swift_addr_t, UInt64) -> Void =
155+
context!.assumingMemoryBound(to: ((swift_addr_t, UInt64) -> Void).self).pointee
154156
ranges.forEach {
155-
body(swift_addr_t($0.address), UInt64($0.size))
157+
callback(swift_addr_t($0.address), UInt64($0.size))
156158
}
157159
})
158160
}

tools/swift-inspect/Sources/swift-inspect/Operations/DumpArray.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
14+
import ArgumentParser
15+
import SwiftRemoteMirror
1416

1517
internal struct DumpArrays: ParsableCommand {
1618
static let configuration = CommandConfiguration(
@@ -23,14 +25,20 @@ internal struct DumpArrays: ParsableCommand {
2325
try inspect(process: options.nameOrPid) { process in
2426
print("Address", "Size", "Count", "Is Class", separator: "\t")
2527
process.iterateHeap { (allocation, size) in
26-
let metadata: swift_reflectioN_ptr_t =
28+
let metadata: UInt =
2729
swift_reflection_metadataForObject(process.context, UInt(allocation))
2830
if metadata == 0 { return }
29-
guard process.context.isContiguousArray(metadata: metadata) else { return }
31+
guard process.context.isContiguousArray(swift_reflection_ptr_t(metadata)) else {
32+
return
33+
}
3034

31-
let isClass = process.context.isArrayOfClass(metdata)
35+
let ReadBytes: RemoteProcess.ReadBytesFunction =
36+
type(of: process).ReadBytes
37+
let this = process.toOpaqueRef()
38+
39+
let isClass = process.context.isArrayOfClass(swift_reflection_ptr_t(metadata))
3240
let count = process.context.arrayCount(swift_reflection_ptr_t(allocation),
33-
process.ReadBytes)
41+
{ ReadBytes(this, $0, UInt64($1), nil) })
3442
print("\(hex: swift_reflection_ptr_t(allocation))\t\(size)\t\(count.map(String.init) ?? "<unknown>")\t\(isClass)")
3543
}
3644
}

0 commit comments

Comments
 (0)