authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-20 13:48:38-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-20 13:48:38-04:00
log9b83fe6b4c289ac7168bb052c3538ccd188ae83c
treebf2d55575f45dde19df5b4132d720b086fc754c7
parent907a7068ce374933630af2e88b57f0cfd10abb72
signature Commit is signed but in an unrecognized format.

fixup and zig fmt


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

std/debug.zig+16-24
......@@ -376,7 +376,6 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
376376 // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records)
377377 // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in,
378378 // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection.
379
380379 const subsection_end_index = sect_offset + subsect_hdr.Length;
381380
382381 while (line_index < subsection_end_index) {
......@@ -692,7 +691,7 @@ pub fn printSourceAtAddressDwarf(
692691 const compile_unit_name = try compile_unit.die.getAttrString(debug_info, DW.AT_name);
693692 if (getLineNumberInfoDwarf(debug_info, compile_unit.*, address - 1)) |line_info| {
694693 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 "???";
696695 try printLineInfo(
697696 out_stream,
698697 line_info,
......@@ -1457,12 +1456,11 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo
14571456 .Const = Constant{
14581457 .signed = signed,
14591458 .payload = switch (size) {
1460 1 => try in_stream.readIntLittle(u8),
1461 2 => try in_stream.readIntLittle(u16),
1462 4 => try in_stream.readIntLittle(u32),
1463 8 => try in_stream.readIntLittle(u64),
1464 -1 => if (signed) @intCast(u64, try readILeb128(in_stream))
1465 else try readULeb128(in_stream),
1459 1 => try in_stream.readIntLittle(u8),
1460 2 => try in_stream.readIntLittle(u16),
1461 4 => try in_stream.readIntLittle(u32),
1462 8 => try in_stream.readIntLittle(u64),
1463 -1 => if (signed) @intCast(u64, try readILeb128(in_stream)) else try readULeb128(in_stream),
14661464 else => @compileError("Invalid size"),
14671465 },
14681466 },
......@@ -1480,10 +1478,10 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 {
14801478fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue {
14811479 return FormValue{
14821480 .Ref = switch (size) {
1483 1 => try in_stream.readIntLittle(u8),
1484 2 => try in_stream.readIntLittle(u16),
1485 4 => try in_stream.readIntLittle(u32),
1486 8 => try in_stream.readIntLittle(u64),
1481 1 => try in_stream.readIntLittle(u8),
1482 2 => try in_stream.readIntLittle(u16),
1483 4 => try in_stream.readIntLittle(u32),
1484 8 => try in_stream.readIntLittle(u64),
14871485 -1 => try readULeb128(in_stream),
14881486 else => unreachable,
14891487 },
......@@ -1992,7 +1990,7 @@ const Func = struct {
19921990 name: ?[]u8,
19931991};
19941992
1995fn getSymbolNameDwarf(di: *DwarfInfo, address: u64) ?[]u8 {
1993fn getSymbolNameDwarf(di: *DwarfInfo, address: u64) ?[]const u8 {
19961994 for (di.func_list.toSliceConst()) |*func| {
19971995 if (func.pc_range) |range| {
19981996 if (address >= range.start and address < range.end) {
......@@ -2036,10 +2034,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void {
20362034 const after_die_offset = try di.dwarf_seekable_stream.getPos();
20372035
20382036 switch (die_obj.tag_id) {
2039 DW.TAG_subprogram,
2040 DW.TAG_inlined_subroutine,
2041 DW.TAG_subroutine,
2042 DW.TAG_entry_point => {
2037 DW.TAG_subprogram, DW.TAG_inlined_subroutine, DW.TAG_subroutine, DW.TAG_entry_point => {
20432038 const fn_name = x: {
20442039 var depth: i32 = 3;
20452040 var this_die_obj = die_obj;
......@@ -2048,22 +2043,19 @@ fn scanAllFunctions(di: *DwarfInfo) !void {
20482043 if (this_die_obj.getAttr(DW.AT_name)) |_| {
20492044 const name = try this_die_obj.getAttrString(di, DW.AT_name);
20502045 break :x name;
2051 }
2052 else if (this_die_obj.getAttr(DW.AT_abstract_origin)) |ref| {
2046 } else if (this_die_obj.getAttr(DW.AT_abstract_origin)) |ref| {
20532047 // Follow the DIE it points to and repeat
20542048 const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin);
20552049 if (ref_offset > next_offset) return error.InvalidDebugInfo;
20562050 try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset);
20572051 this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
2058 }
2059 else if (this_die_obj.getAttr(DW.AT_specification)) |ref| {
2052 } else if (this_die_obj.getAttr(DW.AT_specification)) |ref| {
20602053 // Follow the DIE it points to and repeat
20612054 const ref_offset = try this_die_obj.getAttrRef(DW.AT_abstract_origin);
20622055 if (ref_offset > next_offset) return error.InvalidDebugInfo;
20632056 try di.dwarf_seekable_stream.seekTo(this_unit_offset + ref_offset);
20642057 this_die_obj = (try parseDie1(di, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
2065 }
2066 else {
2058 } else {
20672059 break :x null;
20682060 }
20692061 }
......@@ -2102,7 +2094,7 @@ fn scanAllFunctions(di: *DwarfInfo) !void {
21022094 },
21032095 else => {
21042096 continue;
2105 }
2097 },
21062098 }
21072099
21082100 try di.dwarf_seekable_stream.seekTo(after_die_offset);