diff --git a/stdlib/public/Backtracing/Dwarf.swift b/stdlib/public/Backtracing/Dwarf.swift index 7d9fba1e44733..b908b94043097 100644 --- a/stdlib/public/Backtracing/Dwarf.swift +++ b/stdlib/public/Backtracing/Dwarf.swift @@ -1538,7 +1538,7 @@ struct DwarfReader { var cursor = ImageSourceCursor(source: infoSection, offset: abstractOrigin) - let abbrev = try cursor.readULEB128() + var abbrev = try cursor.readULEB128() if abbrev == 0 { return } @@ -1553,13 +1553,39 @@ struct DwarfReader { return } - let refAttrs = try readDieAttributes( + var refAttrs = try readDieAttributes( at: &cursor, unit: unit, abbrevInfo: abbrevInfo, shouldFetchIndirect: true ) + if let specificationVal = refAttrs[.DW_AT_specification], + case let .reference(specification) = specificationVal { + cursor = ImageSourceCursor(source: infoSection, + offset: specification) + abbrev = try cursor.readULEB128() + if abbrev == 0 { + return + } + + guard let abbrevInfo = unit.abbrevs[abbrev] else { + throw DwarfError.missingAbbrev(abbrev) + } + + let tag = abbrevInfo.tag + if tag != .DW_TAG_subprogram { + return + } + + refAttrs = try readDieAttributes( + at: &cursor, + unit: unit, + abbrevInfo: abbrevInfo, + shouldFetchIndirect: true + ) + } + var name: String? = nil var rawName: String? = nil