@@ -22,28 +22,23 @@ func dumpConformanceCache(context: SwiftReflectionContextRef) throws {
2222}
2323
2424func dumpMetadataAllocations( context: SwiftReflectionContextRef ) throws {
25- var allocations : [ swift_metadata_allocation_t ] = [ ]
26- var metadatas : [ swift_reflection_ptr_t ] = [ ]
27- try context. iterateMetadataAllocations { allocation in
28- allocations. append ( allocation)
29- print ( " Metadata allocation at: \( hex: allocation. Ptr) " +
30- " size: \( allocation. Size) tag: \( allocation. Tag) " )
31- let ptr = context. metadataPointer ( allocation: allocation)
32- if ptr != 0 {
33- metadatas. append ( ptr)
34- }
25+ var allocations = context. allocations
26+ for allocation in allocations {
27+ print ( " Metadata allocation at: \( hex: allocation. ptr) " +
28+ " size: \( allocation. size) tag: \( allocation. tag) " )
3529 }
30+
31+ allocations. sort ( )
32+ let metadatas = allocations. compactMap { $0. metadata ( in: context) }
3633
37- allocations. sort { $0. Ptr < $1. Ptr }
3834 for metadata in metadatas {
39- let name = context. name ( metadata: metadata) ?? " <unknown> "
40- print ( " Metadata \( hex: metadata) " )
41- print ( " Name: \( name) " )
42-
43- if let allocation = allocations. last ( where: { metadata >= $0. Ptr } ) {
44- let offset = metadata - allocation. Ptr
45- print ( " In allocation \( hex: allocation. Ptr) " +
46- " size \( allocation. Size) at offset \( offset) " )
35+ print ( " Metadata \( hex: metadata. ptr) " )
36+ print ( " Name: \( metadata. name) " )
37+
38+ if let allocation = allocations. last ( where: { metadata. ptr >= $0. ptr } ) {
39+ let offset = metadata. ptr - allocation. ptr
40+ print ( " In allocation \( hex: allocation. ptr) " +
41+ " size \( allocation. size) at offset \( offset) " )
4742 } else {
4843 print ( " Not in any known metadata allocation. How strange. " )
4944 }
0 commit comments