| ... | @@ -1655,7 +1655,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con | ... | @@ -1655,7 +1655,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con |
| 1655 | return null; | 1655 | return null; |
| 1656 | } | 1656 | } |
| 1657 | | 1657 | |
| 1658 | fn parseDie1(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Die { | 1658 | fn parseDie(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Die { |
| 1659 | const abbrev_code = try leb.readULEB128(u64, di.dwarf_in_stream); | 1659 | const abbrev_code = try leb.readULEB128(u64, di.dwarf_in_stream); |
| 1660 | if (abbrev_code == 0) return null; | 1660 | if (abbrev_code == 0) return null; |
| 1661 | const table_entry = getAbbrevTableEntry(abbrev_table, abbrev_code) orelse return error.InvalidDebugInfo; | 1661 | const table_entry = getAbbrevTableEntry(abbrev_table, abbrev_code) orelse return error.InvalidDebugInfo; |
| ... | @@ -1675,25 +1675,6 @@ fn parseDie1(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Di | ... | @@ -1675,25 +1675,6 @@ fn parseDie1(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Di |
| 1675 | return result; | 1675 | return result; |
| 1676 | } | 1676 | } |
| 1677 | | 1677 | |
| 1678 | fn parseDie(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !Die { | | |
| 1679 | const abbrev_code = try leb.readULEB128(u64, di.dwarf_in_stream); | | |
| 1680 | const table_entry = getAbbrevTableEntry(abbrev_table, abbrev_code) orelse return error.InvalidDebugInfo; | | |
| 1681 | | | |
| 1682 | var result = Die{ | | |
| 1683 | .tag_id = table_entry.tag_id, | | |
| 1684 | .has_children = table_entry.has_children, | | |
| 1685 | .attrs = ArrayList(Die.Attr).init(di.allocator()), | | |
| 1686 | }; | | |
| 1687 | try result.attrs.resize(table_entry.attrs.len); | | |
| 1688 | for (table_entry.attrs.toSliceConst()) |attr, i| { | | |
| 1689 | result.attrs.items[i] = Die.Attr{ | | |
| 1690 | .id = attr.attr_id, | | |
| 1691 | .value = try parseFormValue(di.allocator(), di.dwarf_in_stream, attr.form_id, is_64), | | |
| 1692 | }; | | |
| 1693 | } | | |
| 1694 | return result; | | |
| 1695 | } | | |
| 1696 | | | |
| 1697 | fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: usize) !LineInfo { | 1678 | fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: usize) !LineInfo { |
| 1698 | const ofile = symbol.ofile orelse return error.MissingDebugInfo; | 1679 | const ofile = symbol.ofile orelse return error.MissingDebugInfo; |
| 1699 | const gop = try di.ofiles.getOrPut(ofile); | 1680 | const gop = try di.ofiles.getOrPut(ofile); |
| ... | @@ -2103,7 +2084,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { | ... | @@ -2103,7 +2084,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { |
| 2103 | const next_unit_pos = this_unit_offset + next_offset; | 2084 | const next_unit_pos = this_unit_offset + next_offset; |
| 2104 | | 2085 | |
| 2105 | while ((try di.dwarf_seekable_stream.getPos()) < next_unit_pos) { | 2086 | while ((try di.dwarf_seekable_stream.getPos()) < next_unit_pos) { |
| 2106 | const die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse continue; | 2087 | const die_obj = (try parseDie(di, abbrev_table, is_64)) orelse continue; |
| 2107 | const after_die_offset = try di.dwarf_seekable_stream.getPos(); | 2088 | const after_die_offset = try di.dwarf_seekable_stream.getPos(); |
| 2108 | | 2089 | |
| 2109 | switch (die_obj.tag_id) { | 2090 | switch (die_obj.tag_id) { |
| ... | @@ -2121,13 +2102,13 @@ fn scanAllFunctions(di: *DwarfInfo) !void { | ... | @@ -2121,13 +2102,13 @@ fn scanAllFunctions(di: *DwarfInfo) !void { |
| 2121 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); | 2102 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); |
| 2122 | if (ref_offset > next_offset) return error.InvalidDebugInfo; | 2103 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
| 2123 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); | 2104 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); |
| 2124 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; | 2105 | this_die_obj = (try parseDie(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 2125 | } else if (this_die_obj.getAttr(DW.AT_specification)) |ref| { | 2106 | } else if (this_die_obj.getAttr(DW.AT_specification)) |ref| { |
| 2126 | // Follow the DIE it points to and repeat | 2107 | // Follow the DIE it points to and repeat |
| 2127 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_specification); | 2108 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_specification); |
| 2128 | if (ref_offset > next_offset) return error.InvalidDebugInfo; | 2109 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
| 2129 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); | 2110 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); |
| 2130 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; | 2111 | this_die_obj = (try parseDie(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 2131 | } else { | 2112 | } else { |
| 2132 | break :x null; | 2113 | break :x null; |
| 2133 | } | 2114 | } |
| ... | @@ -2203,7 +2184,7 @@ fn scanAllCompileUnits(di: *DwarfInfo) !void { | ... | @@ -2203,7 +2184,7 @@ fn scanAllCompileUnits(di: *DwarfInfo) !void { |
| 2203 | try di.dwarf_seekable_stream.seekTo(compile_unit_pos); | 2184 | try di.dwarf_seekable_stream.seekTo(compile_unit_pos); |
| 2204 | | 2185 | |
| 2205 | const compile_unit_die = try di.allocator().create(Die); | 2186 | const compile_unit_die = try di.allocator().create(Die); |
| 2206 | compile_unit_die.* = try parseDie(di, abbrev_table, is_64); | 2187 | compile_unit_die.* = (try parseDie(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 2207 | | 2188 | |
| 2208 | if (compile_unit_die.tag_id != DW.TAG_compile_unit) return error.InvalidDebugInfo; | 2189 | if (compile_unit_die.tag_id != DW.TAG_compile_unit) return error.InvalidDebugInfo; |
| 2209 | | 2190 | |