Skip to content

Commit

Permalink
[Backtracing][Linux] Support the DW_AT_specification attribute.
Browse files Browse the repository at this point in the history
Support parsing the following format:
```
0x0000104b: DW_TAG_subprogram
              DW_AT_specification (0x00000d23 "$s8CrashOpt6level1yyF")
              DW_AT_inline (DW_INL_inlined)
```
  • Loading branch information
DianQK committed Jul 31, 2023
1 parent a22bd27 commit 017d31f
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 017d31f

Please sign in to comment.