Skip to content

Commit

Permalink
Merge pull request #67592 from DianQK/support-the-DW_AT_specification…
Browse files Browse the repository at this point in the history
…-attribute

[Backtracing][Linux] Support the DW_AT_specification attribute.
  • Loading branch information
al45tair authored Aug 6, 2023
2 parents b914fc0 + 017d31f commit 5429100
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions stdlib/public/Backtracing/Dwarf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ struct DwarfReader<S: DwarfSource> {

var cursor = ImageSourceCursor(source: infoSection,
offset: abstractOrigin)
let abbrev = try cursor.readULEB128()
var abbrev = try cursor.readULEB128()
if abbrev == 0 {
return
}
Expand All @@ -1553,13 +1553,39 @@ struct DwarfReader<S: DwarfSource> {
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

Expand Down

0 comments on commit 5429100

Please sign in to comment.