Skip to content

Commit

Permalink
Offset doesn't need such a large int type
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Oct 19, 2022
1 parent dda79ae commit 4fdce4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Sources/Meter/CallStackTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public struct Binary: Codable, Hashable {

public struct Frame: Codable, Hashable {
public var binaryUUID: UUID?
public var offsetIntoBinaryTextSegment: UInt64?
public var offsetIntoBinaryTextSegment: Int?
public var sampleCount: Int?
public var binaryName: String?
public var address: UInt64
public var subFrames: [Frame]?
public var symbolInfo: [SymbolInfo]?

public init(binaryUUID: UUID? = nil, offsetIntoBinaryTextSegment: UInt64? = nil, sampleCount: Int? = nil, binaryName: String? = nil, address: UInt64, subFrames: [Frame]?, symbolInfo: [SymbolInfo]? = nil) {
public init(binaryUUID: UUID? = nil, offsetIntoBinaryTextSegment: Int? = nil, sampleCount: Int? = nil, binaryName: String? = nil, address: UInt64, subFrames: [Frame]?, symbolInfo: [SymbolInfo]? = nil) {
self.binaryUUID = binaryUUID
self.offsetIntoBinaryTextSegment = offsetIntoBinaryTextSegment
self.sampleCount = sampleCount
Expand Down Expand Up @@ -82,12 +82,12 @@ public struct Frame: Codable, Hashable {
return nil
}

let loadAddress = withOffsetAsLoadAddress ? offset : address - offset
let size = address - loadAddress + 1
let loadAddress = withOffsetAsLoadAddress ? offset : Int(address) - offset
let size = Int(address) - loadAddress + 1

return Binary(uuid: uuid,
loadAddress: Int(loadAddress),
approximateSize: Int(size),
loadAddress: loadAddress,
approximateSize: size,
name: binaryName)
}

Expand Down
3 changes: 1 addition & 2 deletions Sources/Meter/ExceptionInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ extension NSException {
}

let subFrames = [frame].compactMap({ $0 })
let offset = binary.map { UInt64($0.loadAddress) }

frame = Frame(binaryUUID: binary?.uuid,
offsetIntoBinaryTextSegment: offset,
offsetIntoBinaryTextSegment: binary?.loadAddress,
binaryName: binary?.name,
address: UInt64(addr),
subFrames: subFrames,
Expand Down

0 comments on commit 4fdce4a

Please sign in to comment.