diff --git a/Other Sources/ADBToolkit/ADBSwiftHelpers.swift b/Other Sources/ADBToolkit/ADBSwiftHelpers.swift index 78975323..58ebdaba 100644 --- a/Other Sources/ADBToolkit/ADBSwiftHelpers.swift +++ b/Other Sources/ADBToolkit/ADBSwiftHelpers.swift @@ -24,12 +24,13 @@ extension ADBBinCueImage { extension BXFileTypes { /// Returns the executable type of the file at the specified URL. /// If the executable type cannot be determined, this method will throw. - static func typeOfExecutable(at URL: URL) throws -> BXExecutableType { + static func typeOfExecutable(at url: URL) throws -> BXExecutableType { let handle: ADBFileHandle do { - handle = try ADBFileHandle(url: URL, options: .openForReading) + handle = try ADBFileHandle(url: url, options: .openForReading) } catch { - throw BXExecutableTypesErrors(.couldNotReadExecutable, userInfo: [NSUnderlyingErrorKey: error]) + throw BXExecutableTypesErrors(.couldNotReadExecutable, userInfo: [NSUnderlyingErrorKey: error, + NSURLErrorKey: url]) } defer { handle.close() diff --git a/Other Sources/ADBToolkit/NSError+ADBErrorHelpers.swift b/Other Sources/ADBToolkit/NSError+ADBErrorHelpers.swift index 07947683..5e75f8d5 100644 --- a/Other Sources/ADBToolkit/NSError+ADBErrorHelpers.swift +++ b/Other Sources/ADBToolkit/NSError+ADBErrorHelpers.swift @@ -24,7 +24,38 @@ private let cxxPrefixes = ["_Z"] private let ADBCallstackSymbolPattern = #"^\d+\s+(\S+)\s+(0x[a-fA-F0-9]+)\s+(.+)\s+\+\s+(\d+)$"# @available(macOS 13.0, *) -private let ADBCallstackSymbolPatternNew = /^\d+\s+(\S+)\s+0x([a-fA-F0-9]+)\s+(.+)\s+\+\s+(\d+)$/ +private let ADBCallstackSymbolPatternNew = Regex { + /^/ + OneOrMore(.digit) + OneOrMore(.whitespace) + Capture { + OneOrMore(.whitespace.inverted) + } + OneOrMore(.whitespace) + "0x" + Capture { + OneOrMore { + CharacterClass( + ("a"..."f"), + ("A"..."F"), + ("0"..."9") + ) + } + } + OneOrMore(.whitespace) + Capture { + OneOrMore { + /./ + } + } + OneOrMore(.whitespace) + "+" + OneOrMore(.whitespace) + Capture { + OneOrMore(.digit) + } + /$/ +} extension NSException { private static func possibleMangledType(from: String) -> MangledFunctionType {