diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-20 00:11:11 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-20 00:11:11 -0400 |
| commit | 2fdf69bc4082c49a571c0ee7bb7441d910def795 (patch) | |
| tree | 85777989a8f3976826612d50204aa655a2b4d8fd /std/debug.zig | |
| parent | ac34841270d34fb2f47ada2960d7281328ec7b25 (diff) | |
| parent | d669db76732a5137f9e37a22d08f5cba319a122d (diff) | |
| download | zig-2fdf69bc4082c49a571c0ee7bb7441d910def795.tar.gz zig-2fdf69bc4082c49a571c0ee7bb7441d910def795.zip | |
Merge pull request #2079 from Sahnvour/issue-2050
Fixes c_ABI tests on windows
Diffstat (limited to 'std/debug.zig')
| -rw-r--r-- | std/debug.zig | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/std/debug.zig b/std/debug.zig index b666e816af..c85a982059 100644 --- a/std/debug.zig +++ b/std/debug.zig @@ -372,18 +372,20 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres const frag_vaddr_start = coff_section.header.virtual_address + line_hdr.RelocOffset; const frag_vaddr_end = frag_vaddr_start + line_hdr.CodeSize; - // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) - // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, - // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. - const subsection_end_index = sect_offset + subsect_hdr.Length; - while (line_index < subsection_end_index) { - const block_hdr = @ptrCast(*pdb.LineBlockFragmentHeader, &subsect_info[line_index]); - line_index += @sizeOf(pdb.LineBlockFragmentHeader); - const start_line_index = line_index; - - const has_column = line_hdr.Flags.LF_HaveColumns; - - if (relative_address >= frag_vaddr_start and relative_address < frag_vaddr_end) { + if (relative_address >= frag_vaddr_start and relative_address < frag_vaddr_end) { + // There is an unknown number of LineBlockFragmentHeaders (and their accompanying line and column records) + // from now on. We will iterate through them, and eventually find a LineInfo that we're interested in, + // breaking out to :subsections. If not, we will make sure to not read anything outside of this subsection. + + const subsection_end_index = sect_offset + subsect_hdr.Length; + + while (line_index < subsection_end_index) { + const block_hdr = @ptrCast(*pdb.LineBlockFragmentHeader, &subsect_info[line_index]); + line_index += @sizeOf(pdb.LineBlockFragmentHeader); + const start_line_index = line_index; + + const has_column = line_hdr.Flags.LF_HaveColumns; + // All line entries are stored inside their line block by ascending start address. // Heuristic: we want to find the last line entry that has a vaddr_start <= relative_address. // This is done with a simple linear search. @@ -427,11 +429,11 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres }; } } - } - // Checking that we are not reading garbage after the (possibly) multiple block fragments. - if (line_index != subsection_end_index) { - return error.InvalidDebugInfo; + // Checking that we are not reading garbage after the (possibly) multiple block fragments. + if (line_index != subsection_end_index) { + return error.InvalidDebugInfo; + } } }, else => {}, @@ -476,6 +478,11 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres } } else |err| switch (err) { error.EndOfFile => {}, + error.FileNotFound => { + setTtyColor(TtyColor.Dim); + try out_stream.write("file not found\n\n"); + setTtyColor(TtyColor.White); + }, else => return err, } } else { @@ -565,11 +572,12 @@ fn populateModule(di: *DebugInfo, mod: *Module) !void { return; const allocator = getDebugInfoAllocator(); - if (mod.mod_info.C11ByteSize != 0) + // At most one can be non-zero. + if (mod.mod_info.C11ByteSize != 0 and mod.mod_info.C13ByteSize != 0) return error.InvalidDebugInfo; if (mod.mod_info.C13ByteSize == 0) - return error.MissingDebugInfo; + return; const modi = di.pdb.getStreamById(mod.mod_info.ModuleSymStream) orelse return error.MissingDebugInfo; @@ -881,8 +889,9 @@ fn openSelfDebugInfoWindows(allocator: *mem.Allocator) !DebugInfo { const obj_file_name = try dbi.readNullTermString(allocator); this_record_len += obj_file_name.len + 1; - const march_forward_bytes = this_record_len % 4; - if (march_forward_bytes != 0) { + if (this_record_len % 4 != 0) { + const round_to_next_4 = (this_record_len | 0x3) + 1; + const march_forward_bytes = round_to_next_4 - this_record_len; try dbi.seekForward(march_forward_bytes); this_record_len += march_forward_bytes; } |
