Skip to content

Commit 5429100

Browse files
authored
Merge pull request #67592 from DianQK/support-the-DW_AT_specification-attribute
[Backtracing][Linux] Support the DW_AT_specification attribute.
2 parents b914fc0 + 017d31f commit 5429100

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

stdlib/public/Backtracing/Dwarf.swift

Lines changed: 28 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,39 @@ 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+
1572+
guard let abbrevInfo = unit.abbrevs[abbrev] else {
1573+
throw DwarfError.missingAbbrev(abbrev)
1574+
}
1575+
1576+
let tag = abbrevInfo.tag
1577+
if tag != .DW_TAG_subprogram {
1578+
return
1579+
}
1580+
1581+
refAttrs = try readDieAttributes(
1582+
at: &cursor,
1583+
unit: unit,
1584+
abbrevInfo: abbrevInfo,
1585+
shouldFetchIndirect: true
1586+
)
1587+
}
1588+
15631589
var name: String? = nil
15641590
var rawName: String? = nil
15651591

0 commit comments

Comments
 (0)