Skip to content

Commit 0953b1d

Browse files
committed
[swift-inspect] Deallocate symbolicator after inspecting a process
This change deallocates the symbolicator. Added CSRelease to symbolication extensions.
1 parent 2f8d9e5 commit 0953b1d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ internal final class DarwinRemoteProcess: RemoteProcess {
174174

175175
deinit {
176176
task_stop_peeking(self.task)
177+
CSRelease(self.symbolicator)
177178
mach_port_deallocate(mach_task_self_, self.task)
178-
mach_port_mod_refs(mach_task_self_, self.task, MACH_PORT_RIGHT_SEND, -1);
179179
}
180180

181181
func symbolicate(_ address: swift_addr_t) -> (module: String?, symbol: String?) {

tools/swift-inspect/Sources/swift-inspect/Symbolication+Extensions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ private func symbol<T>(_ handle: UnsafeMutableRawPointer, _ name: String) -> T {
3333
enum Sym {
3434
static let pidFromHint: @convention(c) (AnyObject) -> pid_t =
3535
symbol(symbolicationHandle, "pidFromHint")
36+
static let CSRelease: @convention(c) (CSTypeRef) -> Void =
37+
symbol(coreSymbolicationHandle, "CSRelease")
3638
static let CSSymbolicatorCreateWithTask: @convention(c) (task_t) -> CSTypeRef =
3739
symbol(coreSymbolicationHandle, "CSSymbolicatorCreateWithTask")
3840
static let CSSymbolicatorGetSymbolOwnerWithNameAtTime:
@@ -100,6 +102,10 @@ func pidFromHint(_ hint: String) -> pid_t? {
100102
return result == 0 ? nil : result
101103
}
102104

105+
func CSRelease(_ sym: CSTypeRef) -> Void {
106+
Sym.CSRelease(sym)
107+
}
108+
103109
func CSSymbolicatorCreateWithTask(_ task: task_t) -> CSTypeRef {
104110
Sym.CSSymbolicatorCreateWithTask(task)
105111
}

0 commit comments

Comments
 (0)