| author | |
| committer | |
| log | df2413cf69a834253bf36a45242a92da6fa8ecae |
| tree | 8f388776a64fc8a5ddeca6300150e170420e5a0b |
| parent | 312ef9558b68898b5402796a94f4bc97a05b308d |
10 files changed, 48 insertions(+), 72 deletions(-)
lib/std/debug.zig-1| ... | ... | @@ -622,7 +622,6 @@ pub const StackTrace = struct { |
| 622 | 622 | return_addresses: []usize, |
| 623 | 623 | /// Indicates whether any stack frames were omitted from `return_addresses`. |
| 624 | 624 | skipped: SkippedAddresses, |
| 625 | ||
| 626 | 625 | }; |
| 627 | 626 | |
| 628 | 627 | /// Indicates how many addresses were skipped in a trace. |
lib/std/debug/Pdb.zig+30-33| ... | ... | @@ -285,7 +285,7 @@ pub const InlineSiteSymIterator = struct { |
| 285 | 285 | .inlinesite, |
| 286 | 286 | .inlinesite2, |
| 287 | 287 | => return @ptrCast(inline_prefix), |
| 288 | else => {} | |
| 288 | else => {}, | |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| ... | ... | @@ -332,9 +332,9 @@ pub const BinaryAnnotation = union(enum) { |
| 332 | 332 | .file_id = self.file_id, |
| 333 | 333 | .code_offset = self.code_offset, |
| 334 | 334 | .code_length = b: { |
| 335 | if (self.code_length) |l| break :b l; | |
| 336 | const end = next_code_offset orelse return null; | |
| 337 | break :b end - self.code_offset; | |
| 335 | if (self.code_length) |l| break :b l; | |
| 336 | const end = next_code_offset orelse return null; | |
| 337 | break :b end - self.code_offset; | |
| 338 | 338 | }, |
| 339 | 339 | }; |
| 340 | 340 | } |
| ... | ... | @@ -345,7 +345,7 @@ pub const BinaryAnnotation = union(enum) { |
| 345 | 345 | .annotations = annotations, |
| 346 | 346 | .curr = .{ |
| 347 | 347 | .line_offset = 0, |
| 348 | .file_id = null, | |
| 348 | .file_id = null, | |
| 349 | 349 | .code_offset = 0, |
| 350 | 350 | .code_length = null, |
| 351 | 351 | }, |
| ... | ... | @@ -395,22 +395,22 @@ pub const BinaryAnnotation = union(enum) { |
| 395 | 395 | }, |
| 396 | 396 | |
| 397 | 397 | // Not emitted by LLVM at the time of writing, and we don't want to add support |
| 398 | // without a test csae. Safe to ignore since we don't use this info right now. | |
| 398 | // without a test case. Safe to ignore since we don't use this info right now. | |
| 399 | 399 | .change_line_end_delta, |
| 400 | 400 | .change_column_start, |
| 401 | 401 | .change_column_end_delta, |
| 402 | 402 | .change_column_end, |
| 403 | => {}, | |
| 403 | => {}, | |
| 404 | 404 | |
| 405 | // Not emitted by LLVM at the time of writing. Various sources conflict on how | |
| 406 | // these opcodes should be interpreted, so we make no attempt to handle them. | |
| 405 | // Not emitted by LLVM at the time of writing. Various sources conflict on how | |
| 406 | // these opcodes should be interpreted, so we make no attempt to handle them. | |
| 407 | 407 | .code_offset, |
| 408 | 408 | .change_code_offset_base, |
| 409 | 409 | .change_range_kind, |
| 410 | 410 | => { |
| 411 | self.annotations = .empty; | |
| 412 | self.prev = null; | |
| 413 | return null; | |
| 411 | self.annotations = .empty; | |
| 412 | self.prev = null; | |
| 413 | return null; | |
| 414 | 414 | }, |
| 415 | 415 | } |
| 416 | 416 | |
| ... | ... | @@ -457,8 +457,8 @@ pub const BinaryAnnotation = union(enum) { |
| 457 | 457 | switch (op) { |
| 458 | 458 | // Microsoft's docs say that invalid is used as padding, though it is left ambiguous |
| 459 | 459 | // whether padding is allowed internally or only after all instructions are complete. |
| 460 | // Empircally, the latter appears to be the case, at lest with the output from LLVM that | |
| 461 | // I've tested. | |
| 460 | // Empirically, the latter appears to be the case, at least with the output from LLVM | |
| 461 | // that I've tested. | |
| 462 | 462 | .invalid => return error.EndOfStream, |
| 463 | 463 | .code_offset => return .{ |
| 464 | 464 | .code_offset = try expect(takePackedU32(reader)), |
| ... | ... | @@ -547,7 +547,7 @@ pub const BinaryAnnotation = union(enum) { |
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | fn expect(value: anytype) error { ReadFailed }!@typeInfo(@TypeOf(value)).error_union.payload { | |
| 550 | fn expect(value: anytype) error{ReadFailed}!@typeInfo(@TypeOf(value)).error_union.payload { | |
| 551 | 551 | comptime assert(@typeInfo(@TypeOf(value)).error_union.error_set == Io.Reader.Error); |
| 552 | 552 | return value catch error.ReadFailed; |
| 553 | 553 | } |
| ... | ... | @@ -661,16 +661,16 @@ pub fn getSymbolName(self: *Pdb, proc_sym: *align(1) const pdb.ProcSym) []const |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | pub const InlineeSourceLine = struct { |
| 664 | signature: pdb.InlineeSourceLineSignature, | |
| 665 | info: *align(1) const pdb.InlineeSourceLine, | |
| 664 | signature: pdb.InlineeSourceLineSignature, | |
| 665 | info: *align(1) const pdb.InlineeSourceLine, | |
| 666 | 666 | |
| 667 | fn lessThan(_: void, lhs: InlineeSourceLine, rhs: InlineeSourceLine) bool { | |
| 668 | return lhs.info.inlinee < rhs.info.inlinee; | |
| 669 | } | |
| 667 | fn lessThan(_: void, lhs: InlineeSourceLine, rhs: InlineeSourceLine) bool { | |
| 668 | return lhs.info.inlinee < rhs.info.inlinee; | |
| 669 | } | |
| 670 | 670 | |
| 671 | fn compare(inlinee: u32, self: InlineeSourceLine) std.math.Order { | |
| 672 | return std.math.order(inlinee, self.info.inlinee); | |
| 673 | } | |
| 671 | fn compare(inlinee: u32, self: InlineeSourceLine) std.math.Order { | |
| 672 | return std.math.order(inlinee, self.info.inlinee); | |
| 673 | } | |
| 674 | 674 | }; |
| 675 | 675 | |
| 676 | 676 | /// Returns all `InlineeSourceLine`s for a given module with the given inlinee. Ideally there would |
| ... | ... | @@ -694,7 +694,7 @@ pub fn getInlineeSourceLines( |
| 694 | 694 | |
| 695 | 695 | // Linearly scan to the first match |
| 696 | 696 | const begin = b: { |
| 697 | var begin = any; | |
| 697 | var begin = any; | |
| 698 | 698 | while (begin > 0) { |
| 699 | 699 | const prev = begin - 1; |
| 700 | 700 | if (mod.inlinee_source_lines[prev].info.inlinee != inlinee) break; |
| ... | ... | @@ -706,10 +706,9 @@ pub fn getInlineeSourceLines( |
| 706 | 706 | // Linearly scan to the last match |
| 707 | 707 | const end = b: { |
| 708 | 708 | var end = any + 1; |
| 709 | while ( | |
| 710 | end < mod.inlinee_source_lines.len and | |
| 711 | mod.inlinee_source_lines[end].info.inlinee == inlinee | |
| 712 | ) : (end += 1) {} | |
| 709 | while (end < mod.inlinee_source_lines.len and | |
| 710 | mod.inlinee_source_lines[end].info.inlinee == inlinee) : (end += 1) | |
| 711 | {} | |
| 713 | 712 | break :b end; |
| 714 | 713 | }; |
| 715 | 714 | |
| ... | ... | @@ -844,8 +843,7 @@ pub fn getModule(self: *Pdb, index: usize) !?*Module { |
| 844 | 843 | while (subsects.takeStructPointer(pdb.DebugSubsectionHeader) catch null) |subsect_hdr| { |
| 845 | 844 | var subsect: Io.Reader = .fixed(subsects.take(subsect_hdr.length) catch return null); |
| 846 | 845 | if (subsect_hdr.kind == .inlinee_lines) { |
| 847 | const inlinee_source_line_signature = subsect.takeEnum(pdb.InlineeSourceLineSignature, .little) | |
| 848 | catch return error.InvalidDebugInfo; | |
| 846 | const inlinee_source_line_signature = subsect.takeEnum(pdb.InlineeSourceLineSignature, .little) catch return error.InvalidDebugInfo; | |
| 849 | 847 | const has_extra_files = switch (inlinee_source_line_signature) { |
| 850 | 848 | .normal => false, |
| 851 | 849 | .ex => true, |
| ... | ... | @@ -855,8 +853,7 @@ pub fn getModule(self: *Pdb, index: usize) !?*Module { |
| 855 | 853 | if (has_extra_files) { |
| 856 | 854 | const file_count = subsect.takeInt(u32, .little) catch |
| 857 | 855 | return error.InvalidDebugInfo; |
| 858 | const file_bytes = std.math.mul(usize, file_count, @sizeOf(u32)) | |
| 859 | catch return error.InvalidDebugInfo; | |
| 856 | const file_bytes = std.math.mul(usize, file_count, @sizeOf(u32)) catch return error.InvalidDebugInfo; | |
| 860 | 857 | subsect.discardAll(file_bytes) catch |
| 861 | 858 | return error.InvalidDebugInfo; |
| 862 | 859 | } |
| ... | ... | @@ -868,7 +865,7 @@ pub fn getModule(self: *Pdb, index: usize) !?*Module { |
| 868 | 865 | } |
| 869 | 866 | } |
| 870 | 867 | } |
| 871 | ||
| 868 | ||
| 872 | 869 | std.mem.sort(InlineeSourceLine, inlinee_source_lines.items, {}, InlineeSourceLine.lessThan); |
| 873 | 870 | break :b try inlinee_source_lines.toOwnedSlice(gpa); |
| 874 | 871 | }; |
lib/std/debug/SelfInfo/MachO.zig-14| ... | ... | @@ -22,20 +22,6 @@ pub fn deinit(si: *SelfInfo, io: Io) void { |
| 22 | 22 | si.modules.deinit(gpa); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | pub const SymbolIterator = struct { | |
| 26 | curr: ?Error!std.debug.Symbol, | |
| 27 | ||
| 28 | pub fn deinit(self: *SymbolIterator, _: Io) void { | |
| 29 | self.* = undefined; | |
| 30 | } | |
| 31 | ||
| 32 | pub fn next(self: *SymbolIterator) ?Error!std.debug.Symbol { | |
| 33 | const result = self.curr; | |
| 34 | self.curr = null; | |
| 35 | return result; | |
| 36 | } | |
| 37 | }; | |
| 38 | ||
| 39 | 25 | pub fn getSymbols(si: *SelfInfo, io: Io, address: usize, resolve_inline_callers: bool) Error![]std.debug.Symbol { |
| 40 | 26 | _ = resolve_inline_callers; |
| 41 | 27 |
lib/std/pdb.zig+1-6| ... | ... | @@ -616,11 +616,7 @@ pub const InlineSiteSym2 = extern struct { |
| 616 | 616 | invocations: u32, |
| 617 | 617 | }; |
| 618 | 618 | |
| 619 | pub const InlineeSourceLineSignature = enum(u32) { | |
| 620 | normal = 0, | |
| 621 | ex = 1, | |
| 622 | _ | |
| 623 | }; | |
| 619 | pub const InlineeSourceLineSignature = enum(u32) { normal = 0, ex = 1, _ }; | |
| 624 | 620 | |
| 625 | 621 | pub const InlineeSourceLine = extern struct { |
| 626 | 622 | inlinee: u32, |
| ... | ... | @@ -651,4 +647,3 @@ pub const BinaryAnnotationOpcode = enum(u8) { |
| 651 | 647 | change_code_length_and_code_offset = 12, |
| 652 | 648 | change_column_end = 13, |
| 653 | 649 | }; |
| 654 |
lib/std/testing/FailingAllocator.zig+2-2| ... | ... | @@ -138,8 +138,8 @@ pub fn getStackTrace(self: *FailingAllocator) std.debug.StackTrace { |
| 138 | 138 | len += 1; |
| 139 | 139 | } |
| 140 | 140 | return .{ |
| 141 | .return_addresses = &self.stack_addresses, | |
| 142 | .index = len, | |
| 141 | .return_addresses = self.stack_addresses[0..len], | |
| 142 | .skipped = if (len == self.stack_addresses.len) .unknown else .none, | |
| 143 | 143 | }; |
| 144 | 144 | } |
| 145 | 145 |
test/cases/disable_stack_tracing.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ pub fn main() !void { |
| 9 | 9 | |
| 10 | 10 | const captured_st = try foo(&stdout.interface, &st_buf); |
| 11 | 11 | try std.debug.writeStackTrace(&captured_st, .{ .writer = &stdout.interface, .mode = .no_color }); |
| 12 | try stdout.interface.print("stack trace index: {d}\n", .{captured_st.index}); | |
| 12 | try stdout.interface.print("stack trace index: {d}\n", .{captured_st.return_addresses.len}); | |
| 13 | 13 | |
| 14 | 14 | try stdout.interface.flush(); |
| 15 | 15 | } |
test/error_traces.zig+1-2| ... | ... | @@ -466,8 +466,7 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext, os: std.Target. |
| 466 | 466 | \\} |
| 467 | 467 | , |
| 468 | 468 | .expect_error = "ThisIsSoSad", |
| 469 | .expect_trace = | |
| 470 | switch (os) { | |
| 469 | .expect_trace = switch (os) { | |
| 471 | 470 | // LLVM doesn't emit column info in the binary annotations for inlinee callees in PDBs, |
| 472 | 471 | // so our expected result is slightly different for Windows than on other operating |
| 473 | 472 | // systems. |
test/src/convert-stack-trace.zig+10-9| ... | ... | @@ -52,23 +52,24 @@ pub fn main(init: std.process.Init) !void { |
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | // If both the row and column are present, this it he column end. Otherwise it's the line end. | |
| 56 | 55 | const src_pos_end = std.mem.indexOf(u8, in_line, ": 0x") orelse { |
| 57 | 56 | try w.writeAll(in_line); |
| 58 | 57 | continue; |
| 59 | 58 | }; |
| 60 | const src_row_or_path_end = std.mem.lastIndexOfScalar(u8, in_line[0..src_pos_end], ':') orelse { | |
| 61 | try w.writeAll(in_line); | |
| 62 | continue; | |
| 59 | const src_pos_start = b: { | |
| 60 | const postfix = ".zig:"; | |
| 61 | const postfix_index = std.mem.lastIndexOf(u8, in_line[0..src_pos_end], postfix) orelse { | |
| 62 | try w.writeAll(in_line); | |
| 63 | continue; | |
| 64 | }; | |
| 65 | break :b postfix_index + postfix.len; | |
| 63 | 66 | }; |
| 64 | const src_path_end = std.mem.lastIndexOfScalar(u8, in_line[0..src_row_or_path_end], ':') | |
| 65 | orelse src_row_or_path_end; | |
| 66 | 67 | |
| 67 | const addr_end = std.mem.indexOfPos(u8, in_line, src_pos_end, " in ") orelse { | |
| 68 | const addr_end = std.mem.findPos(u8, in_line, src_pos_end, " in ") orelse { | |
| 68 | 69 | try w.writeAll(in_line); |
| 69 | 70 | continue; |
| 70 | 71 | }; |
| 71 | const symbol_end = std.mem.indexOfPos(u8, in_line, addr_end, " (") orelse { | |
| 72 | const symbol_end = std.mem.findPos(u8, in_line, addr_end, " (") orelse { | |
| 72 | 73 | try w.writeAll(in_line); |
| 73 | 74 | continue; |
| 74 | 75 | }; |
| ... | ... | @@ -87,7 +88,7 @@ pub fn main(init: std.process.Init) !void { |
| 87 | 88 | // |
| 88 | 89 | // ...with that first '_' being replaced by its basename. |
| 89 | 90 | |
| 90 | const src_path = in_line[0..src_path_end]; | |
| 91 | const src_path = in_line[0..src_pos_start]; | |
| 91 | 92 | const basename_start = if (std.mem.lastIndexOfAny(u8, src_path, "/\\")) |i| i + 1 else 0; |
| 92 | 93 | const symbol_start = addr_end + " in ".len; |
| 93 | 94 | try w.writeAll(in_line[basename_start..src_pos_end]); |
test/standalone/coff_dwarf/main.zig+2-2| ... | ... | @@ -12,13 +12,13 @@ pub fn main(init: std.process.Init) void { |
| 12 | 12 | var add_addr: usize = undefined; |
| 13 | 13 | _ = add(1, 2, &add_addr); |
| 14 | 14 | |
| 15 | const symbols = di.getSymbols(io, add_addr) catch |err| fatal("failed to get symbol: {t}", .{err}); | |
| 15 | const symbols = di.getSymbols(io, add_addr, false) catch |err| fatal("failed to get symbol: {t}", .{err}); | |
| 16 | 16 | const debug_gpa = std.debug.getDebugInfoAllocator(); |
| 17 | 17 | defer for (symbols) |symbol| { |
| 18 | 18 | if (symbol.source_location) |sl| { |
| 19 | 19 | debug_gpa.free(sl.file_name); |
| 20 | 20 | } |
| 21 | } | |
| 21 | }; | |
| 22 | 22 | |
| 23 | 23 | if (symbols.len != 1) fatal("expected 1 symbol, found {}", .{symbols.len}); |
| 24 | 24 | const symbol = symbols[0]; |
test/tests.zig+1-2| ... | ... | @@ -2168,7 +2168,6 @@ pub fn addErrorTraceTests( |
| 2168 | 2168 | error_traces.addCases(darling_cases, .macos); |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | ||
| 2172 | 2171 | return step; |
| 2173 | 2172 | } |
| 2174 | 2173 | |
| ... | ... | @@ -2291,7 +2290,7 @@ pub fn addCliTests(b: *std.Build) *Step { |
| 2291 | 2290 | \\ return num * num; |
| 2292 | 2291 | \\} |
| 2293 | 2292 | \\extern fn zig_panic() noreturn; |
| 2294 | \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace, _: ?usize) noreturn { | |
| 2293 | \\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace, _: ?usize) noreturn { | |
| 2295 | 2294 | \\ _ = msg; |
| 2296 | 2295 | \\ _ = error_return_trace; |
| 2297 | 2296 | \\ zig_panic(); |