Skip to content

Commit 6cce54d

Browse files
committed
[Backtracing][Linux] Support the DW_AT_specification attribute.
Support parsing the following format: ``` 0x0000104b: DW_TAG_subprogram DW_AT_specification (0x00000d23 "$s8CrashOpt6level1yyF") DW_AT_inline (DW_INL_inlined) ```
1 parent 8af81a3 commit 6cce54d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

stdlib/public/Backtracing/Dwarf.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ struct DwarfReader<S: DwarfSource> {
15381538

15391539
var cursor = ImageSourceCursor(source: infoSection,
15401540
offset: abstractOrigin)
1541-
let abbrev = try cursor.readULEB128()
1541+
var abbrev = try cursor.readULEB128()
15421542
if abbrev == 0 {
15431543
return
15441544
}
@@ -1553,13 +1553,32 @@ struct DwarfReader<S: DwarfSource> {
15531553
return
15541554
}
15551555

1556-
let refAttrs = try readDieAttributes(
1556+
var refAttrs = try readDieAttributes(
15571557
at: &cursor,
15581558
unit: unit,
15591559
abbrevInfo: abbrevInfo,
15601560
shouldFetchIndirect: true
15611561
)
15621562

1563+
if let specificationVal = refAttrs[.DW_AT_specification],
1564+
case let .reference(specification) = specificationVal {
1565+
cursor = ImageSourceCursor(source: infoSection,
1566+
offset: specification)
1567+
abbrev = try cursor.readULEB128()
1568+
if abbrev == 0 {
1569+
return
1570+
}
1571+
guard let abbrevInfo = unit.abbrevs[abbrev] else {
1572+
throw DwarfError.missingAbbrev(abbrev)
1573+
}
1574+
refAttrs = try readDieAttributes(
1575+
at: &cursor,
1576+
unit: unit,
1577+
abbrevInfo: abbrevInfo,
1578+
shouldFetchIndirect: true
1579+
)
1580+
}
1581+
15631582
var name: String? = nil
15641583
var rawName: String? = nil
15651584

0 commit comments

Comments
 (0)