Skip to content

[Backtracing][Linux] Support the DW_AT_specification attribute. #67592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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