| ... | @@ -376,7 +376,6 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres | ... | @@ -376,7 +376,6 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 376 | // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) | 376 | // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) |
| 377 | // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, | 377 | // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, |
| 378 | // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. | 378 | // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. |
| 379 | | | |
| 380 | const subsection_end_index = sect_offset + subsect_hdr.Length; | 379 | const subsection_end_index = sect_offset + subsect_hdr.Length; |
| 381 | | 380 | |
| 382 | while (line_index < subsection_end_index) { | 381 | while (line_index < subsection_end_index) { |
| ... | @@ -692,7 +691,7 @@ pub fn printSourceAtAddressDwarf( | ... | @@ -692,7 +691,7 @@ pub fn printSourceAtAddressDwarf( |
| 692 | const compile_unit_name = try compile_unit.die.getAttrString(debug_info, DW.AT_name); | 691 | const compile_unit_name = try compile_unit.die.getAttrString(debug_info, DW.AT_name); |
| 693 | if (getLineNumberInfoDwarf(debug_info, compile_unit.*, address - 1)) |line_info| { | 692 | if (getLineNumberInfoDwarf(debug_info, compile_unit.*, address - 1)) |line_info| { |
| 694 | defer line_info.deinit(); | 693 | defer line_info.deinit(); |
| 695 | const symbol_name = getSymbolNameDwarf(debug_info, address - 1) orelse "???"[0..2]; | 694 | const symbol_name = getSymbolNameDwarf(debug_info, address - 1) orelse "???"; |
| 696 | try printLineInfo( | 695 | try printLineInfo( |
| 697 | out_stream, | 696 | out_stream, |
| 698 | line_info, | 697 | line_info, |
| ... | @@ -1457,12 +1456,11 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo | ... | @@ -1457,12 +1456,11 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo |
| 1457 | .Const = Constant{ | 1456 | .Const = Constant{ |
| 1458 | .signed = signed, | 1457 | .signed = signed, |
| 1459 | .payload = switch (size) { | 1458 | .payload = switch (size) { |
| 1460 | 1 => try in_stream.readIntLittle(u8), | 1459 | 1 => try in_stream.readIntLittle(u8), |
| 1461 | 2 => try in_stream.readIntLittle(u16), | 1460 | 2 => try in_stream.readIntLittle(u16), |
| 1462 | 4 => try in_stream.readIntLittle(u32), | 1461 | 4 => try in_stream.readIntLittle(u32), |
| 1463 | 8 => try in_stream.readIntLittle(u64), | 1462 | 8 => try in_stream.readIntLittle(u64), |
| 1464 | -1 => if (signed) @intCast(u64, try readILeb128(in_stream)) | 1463 | -1 => if (signed) @intCast(u64, try readILeb128(in_stream)) else try readULeb128(in_stream), |
| 1465 | else try readULeb128(in_stream), | | |
| 1466 | else => @compileError("Invalid size"), | 1464 | else => @compileError("Invalid size"), |
| 1467 | }, | 1465 | }, |
| 1468 | }, | 1466 | }, |
| ... | @@ -1480,10 +1478,10 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 { | ... | @@ -1480,10 +1478,10 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 { |
| 1480 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue { | 1478 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue { |
| 1481 | return FormValue{ | 1479 | return FormValue{ |
| 1482 | .Ref = switch (size) { | 1480 | .Ref = switch (size) { |
| 1483 | 1 => try in_stream.readIntLittle(u8), | 1481 | 1 => try in_stream.readIntLittle(u8), |
| 1484 | 2 => try in_stream.readIntLittle(u16), | 1482 | 2 => try in_stream.readIntLittle(u16), |
| 1485 | 4 => try in_stream.readIntLittle(u32), | 1483 | 4 => try in_stream.readIntLittle(u32), |
| 1486 | 8 => try in_stream.readIntLittle(u64), | 1484 | 8 => try in_stream.readIntLittle(u64), |
| 1487 | -1 => try readULeb128(in_stream), | 1485 | -1 => try readULeb128(in_stream), |
| 1488 | else => unreachable, | 1486 | else => unreachable, |
| 1489 | }, | 1487 | }, |
| ... | @@ -1992,7 +1990,7 @@ const Func = struct { | ... | @@ -1992,7 +1990,7 @@ const Func = struct { |
| 1992 | name: ?[]u8, | 1990 | name: ?[]u8, |
| 1993 | }; | 1991 | }; |
| 1994 | | 1992 | |
| 1995 | fn getSymbolNameDwarf(di: *DwarfInfo, address: u64) ?[]u8 { | 1993 | fn getSymbolNameDwarf(di: *DwarfInfo, address: u64) ?[]const u8 { |
| 1996 | for (di.func_list.toSliceConst()) |*func| { | 1994 | for (di.func_list.toSliceConst()) |*func| { |
| 1997 | if (func.pc_range) |range| { | 1995 | if (func.pc_range) |range| { |
| 1998 | if (address >= range.start and address < range.end) { | 1996 | if (address >= range.start and address < range.end) { |
| ... | @@ -2036,10 +2034,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { | ... | @@ -2036,10 +2034,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { |
| 2036 | const after_die_offset = try di.dwarf_seekable_stream.getPos(); | 2034 | const after_die_offset = try di.dwarf_seekable_stream.getPos(); |
| 2037 | | 2035 | |
| 2038 | switch (die_obj.tag_id) { | 2036 | switch (die_obj.tag_id) { |
| 2039 | DW.TAG_subprogram, | 2037 | DW.TAG_subprogram, DW.TAG_inlined_subroutine, DW.TAG_subroutine, DW.TAG_entry_point => { |
| 2040 | DW.TAG_inlined_subroutine, | | |
| 2041 | DW.TAG_subroutine, | | |
| 2042 | DW.TAG_entry_point => { | | |
| 2043 | const fn_name = x: { | 2038 | const fn_name = x: { |
| 2044 | var depth: i32 = 3; | 2039 | var depth: i32 = 3; |
| 2045 | var this_die_obj = die_obj; | 2040 | var this_die_obj = die_obj; |
| ... | @@ -2048,22 +2043,19 @@ fn scanAllFunctions(di: *DwarfInfo) !void { | ... | @@ -2048,22 +2043,19 @@ fn scanAllFunctions(di: *DwarfInfo) !void { |
| 2048 | if (this_die_obj.getAttr(DW.AT_name)) |_| { | 2043 | if (this_die_obj.getAttr(DW.AT_name)) |_| { |
| 2049 | const name = try this_die_obj.getAttrString(di, DW.AT_name); | 2044 | const name = try this_die_obj.getAttrString(di, DW.AT_name); |
| 2050 | break :x name; | 2045 | break :x name; |
| 2051 | } | 2046 | } else if (this_die_obj.getAttr(DW.AT_abstract_origin)) |ref| { |
| 2052 | else if (this_die_obj.getAttr(DW.AT_abstract_origin)) |ref| { | | |
| 2053 | // Follow the DIE it points to and repeat | 2047 | // Follow the DIE it points to and repeat |
| 2054 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); | 2048 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); |
| 2055 | if (ref_offset > next_offset) return error.InvalidDebugInfo; | 2049 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
| 2056 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); | 2050 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); |
| 2057 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; | 2051 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 2058 | } | 2052 | } else if (this_die_obj.getAttr(DW.AT_specification)) |ref| { |
| 2059 | else if (this_die_obj.getAttr(DW.AT_specification)) |ref| { | | |
| 2060 | // Follow the DIE it points to and repeat | 2053 | // Follow the DIE it points to and repeat |
| 2061 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); | 2054 | const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin); |
| 2062 | if (ref_offset > next_offset) return error.InvalidDebugInfo; | 2055 | if (ref_offset > next_offset) return error.InvalidDebugInfo; |
| 2063 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); | 2056 | try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset); |
| 2064 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; | 2057 | this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo; |
| 2065 | } | 2058 | } else { |
| 2066 | else { | | |
| 2067 | break :x null; | 2059 | break :x null; |
| 2068 | } | 2060 | } |
| 2069 | } | 2061 | } |
| ... | @@ -2102,7 +2094,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { | ... | @@ -2102,7 +2094,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void { |
| 2102 | }, | 2094 | }, |
| 2103 | else => { | 2095 | else => { |
| 2104 | continue; | 2096 | continue; |
| 2105 | } | 2097 | }, |
| 2106 | } | 2098 | } |
| 2107 | | 2099 | |
| 2108 | try di.dwarf_seekable_stream.seekTo(after_die_offset); | 2100 | try di.dwarf_seekable_stream.seekTo(after_die_offset); |