Skip to content

Commit e3afb32

Browse files
committed
[Backtracing] For DWARF 3, skip maximum_operations_per_instruction
DWARF 3 doesn't have the `maximum_operations_per_instruction` field in the line number header. As a result, we were mis-reading the subsequent fields in the DWARF line table header. rdar://168996222
1 parent 190cdb4 commit e3afb32

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/RuntimeModule/Dwarf.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,13 @@ struct DwarfReader<S: DwarfSource & AnyObject> {
851851
// .6 minimum_instruction_length
852852
let minimumInstructionLength = UInt(try cursor.read(as: Dwarf_Byte.self))
853853

854-
// .7 maximum_operations_per_instruction
855-
let maximumOpsPerInstruction = UInt(try cursor.read(as: Dwarf_Byte.self))
854+
let maximumOpsPerInstruction: UInt
855+
if version >= 4 {
856+
// .7 maximum_operations_per_instruction
857+
maximumOpsPerInstruction = UInt(try cursor.read(as: Dwarf_Byte.self))
858+
} else {
859+
maximumOpsPerInstruction = 1
860+
}
856861

857862
// .8 default_is_stmt
858863
let defaultIsStmt = try cursor.read(as: Dwarf_Byte.self) != 0

0 commit comments

Comments
 (0)