File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
tools/swift-inspect/Sources Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,6 @@ public class MemoryMap {
25
25
public let device : String
26
26
public let inode : UInt64
27
27
public let pathname : String ?
28
-
29
- public func isHeapRegion( ) -> Bool {
30
- guard let name = self . pathname else { return false }
31
- if name == " [anon:libc_malloc] " { return true }
32
- if name. hasPrefix ( " [anon:scudo: " ) { return true }
33
- if name. hasPrefix ( " [anon:GWP-ASan " ) { return true }
34
- return false
35
- }
36
28
}
37
29
38
30
public let entries : [ Entry ]
Original file line number Diff line number Diff line change @@ -18,6 +18,18 @@ import LinuxSystemHeaders
18
18
import SwiftInspectLinux
19
19
import SwiftRemoteMirror
20
20
21
+ extension MemoryMap . Entry {
22
+ public func isHeapRegion( ) -> Bool {
23
+ guard let name = self . pathname else { return false }
24
+ // The heap region naming convention is found in AOSP's libmemunreachable at
25
+ // android/platform/system/memory/libmemunreachable/MemUnreachable.cpp.
26
+ if name == " [anon:libc_malloc] " { return true }
27
+ if name. hasPrefix ( " [anon:scudo: " ) { return true }
28
+ if name. hasPrefix ( " [anon:GWP-ASan " ) { return true }
29
+ return false
30
+ }
31
+ }
32
+
21
33
internal final class AndroidRemoteProcess : LinuxRemoteProcess {
22
34
enum RemoteProcessError : Error {
23
35
case missingSymbol( _ name: String )
@@ -39,6 +51,9 @@ internal final class AndroidRemoteProcess: LinuxRemoteProcess {
39
51
40
52
override internal func iterateHeap( _ body: ( swift_addr_t , UInt64 ) -> Void ) {
41
53
for entry in self . memoryMap. entries {
54
+ // Limiting malloc_iterate calls to only memory regions that are known
55
+ // to contain heap allocations is not strictly necessary but it does
56
+ // significantly improves the speed of heap iteration.
42
57
guard entry. isHeapRegion ( ) else { continue }
43
58
44
59
// collect all of the allocations in this heap region
You can’t perform that action at this time.
0 commit comments