authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-11 16:19:46-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-12 01:40:55-04:00
log68b49f74c45f9d46ceca0196ad5b2edeee30e26f
treec3e26eb798949d740e8d93a04ea88a868607e1ff
parentf36b8fd7b2c89d46dba95eca05b60487638dd2a0
signaturelock-open Commit is signed but in an unrecognized format.

consolidate std.debug.parseDie and std.debug.parseDie1


1 files changed, 5 insertions(+), 24 deletions(-)

std/debug.zig+5-24
......@@ -1655,7 +1655,7 @@ fn getAbbrevTableEntry(abbrev_table: *const AbbrevTable, abbrev_code: u64) ?*con
16551655 return null;
16561656}
16571657
1658fn parseDie1(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Die {
1658fn parseDie(di: *DwarfInfo, abbrev_table: *const AbbrevTable, is_64: bool) !?Die {
16591659 const abbrev_code = try leb.readULEB128(u64, di.dwarf_in_stream);
16601660 if (abbrev_code == 0) return null;
16611661 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
16751675 return result;
16761676}
16771677
1678fn 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
16971678fn getLineNumberInfoMacOs(di: *DebugInfo, symbol: MachoSymbol, target_address: usize) !LineInfo {
16981679 const ofile = symbol.ofile orelse return error.MissingDebugInfo;
16991680 const gop = try di.ofiles.getOrPut(ofile);
......@@ -2103,7 +2084,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void {
21032084 const next_unit_pos = this_unit_offset + next_offset;
21042085
21052086 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;
21072088 const after_die_offset = try di.dwarf_seekable_stream.getPos();
21082089
21092090 switch (die_obj.tag_id) {
......@@ -2121,13 +2102,13 @@ fn scanAllFunctions(di: *DwarfInfo) !void {
21212102 const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin);
21222103 if (ref_offset > next_offset) return error.InvalidDebugInfo;
21232104 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;
21252106 } else if (this_die_obj.getAttr(DW.AT_specification)) |ref| {
21262107 // Follow the DIE it points to and repeat
21272108 const ref_offset = try this_die_obj.getAttrRef(DW.AT_specification);
21282109 if (ref_offset > next_offset) return error.InvalidDebugInfo;
21292110 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;
21312112 } else {
21322113 break :x null;
21332114 }
......@@ -2203,7 +2184,7 @@ fn scanAllCompileUnits(di: *DwarfInfo) !void {
22032184 try di.dwarf_seekable_stream.seekTo(compile_unit_pos);
22042185
22052186 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;
22072188
22082189 if (compile_unit_die.tag_id != DW.TAG_compile_unit) return error.InvalidDebugInfo;
22092190