11
11
//===----------------------------------------------------------------------===//
12
12
13
13
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
14
+ import ArgumentParser
15
+ import SwiftRemoteMirror
14
16
15
17
internal struct DumpArrays : ParsableCommand {
16
18
static let configuration = CommandConfiguration (
@@ -23,14 +25,20 @@ internal struct DumpArrays: ParsableCommand {
23
25
try inspect ( process: options. nameOrPid) { process in
24
26
print ( " Address " , " Size " , " Count " , " Is Class " , separator: " \t " )
25
27
process. iterateHeap { ( allocation, size) in
26
- let metadata : swift_reflectioN_ptr_t =
28
+ let metadata : UInt =
27
29
swift_reflection_metadataForObject ( process. context, UInt ( allocation) )
28
30
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
+ }
30
34
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) )
32
40
let count = process. context. arrayCount ( swift_reflection_ptr_t ( allocation) ,
33
- process . ReadBytes)
41
+ { ReadBytes ( this , $0 , UInt64 ( $1 ) , nil ) } )
34
42
print ( " \( hex: swift_reflection_ptr_t ( allocation) ) \t \( size) \t \( count. map ( String . init) ?? " <unknown> " ) \t \( isClass) " )
35
43
}
36
44
}
0 commit comments