Skip to content

Commit 1c3684f

Browse files
committed
make sure crashed is explicitly set if absent, and that symbolication options can be passed in
1 parent 740f2d4 commit 1c3684f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

stdlib/public/RuntimeModule/CrashLog.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ public struct CrashLog<Address: FixedWidthInteger>: Codable {
122122
}
123123

124124
public struct Thread: Codable {
125+
enum CodingKeys: String, CodingKey {
126+
case name
127+
case crashed
128+
case registers
129+
case frames
130+
}
131+
125132
public var name: String?
126133
public var crashed: Bool
127134
public var registers: [String:String]?
@@ -134,6 +141,14 @@ public struct CrashLog<Address: FixedWidthInteger>: Codable {
134141
self.registers = registers
135142
self.frames = frames
136143
}
144+
145+
public init(from decoder: Decoder) throws {
146+
let values = try decoder.container(keyedBy: CodingKeys.self)
147+
name = try values.decodeIfPresent(String.self, forKey: .name)
148+
crashed = try values.decodeIfPresent(Bool.self, forKey: .crashed) ?? false
149+
registers = try values.decodeIfPresent([String:String].self, forKey: .registers)
150+
frames = try values.decode([Frame].self, forKey: .frames)
151+
}
137152
}
138153

139154
public struct Image: Codable {
@@ -412,13 +427,19 @@ extension CrashLog {
412427
}
413428
}
414429

415-
public mutating func symbolicate(allThreads: Bool = false) {
430+
public mutating func symbolicate(
431+
allThreads: Bool = false,
432+
options: Backtrace.SymbolicationOptions = .default) {
433+
416434
let images = imageMap()
417435

418436
func symbolicateThread(_ thread: CrashLog.Thread) -> CrashLog.Thread {
419437
var thread = thread
420438
let backtrace: Backtrace = thread.backtrace(architecture: architecture, images: images)
421-
if let symbolicatedBacktrace = backtrace.symbolicated(with: images) {
439+
440+
if let symbolicatedBacktrace = backtrace.symbolicated(
441+
with: images, options: options) {
442+
422443
thread.updateWithBacktrace(symbolicatedBacktrace: symbolicatedBacktrace)
423444
}
424445
return thread

0 commit comments

Comments
 (0)