Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,10 @@ pub noinline fn returnError(st: *StackTrace) void {
}

pub inline fn addErrRetTraceAddr(st: *StackTrace, addr: usize) void {
st.instruction_addresses[st.index & (st.instruction_addresses.len - 1)] = addr;
st.index +%= 1;
if (st.index < st.instruction_addresses.len)
st.instruction_addresses[st.index] = addr;

st.index += 1;
}

const std = @import("std.zig");
Expand Down
8 changes: 8 additions & 0 deletions lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,14 @@ pub fn writeStackTrace(
const return_address = stack_trace.instruction_addresses[frame_index];
try printSourceAtAddress(debug_info, out_stream, return_address - 1, tty_config);
}

if (stack_trace.index > stack_trace.instruction_addresses.len) {
const dropped_frames = stack_trace.index - stack_trace.instruction_addresses.len;

tty_config.setColor(out_stream, .Bold);
try out_stream.print("({d} additional stack frames skipped...)\n", .{dropped_frames});
tty_config.setColor(out_stream, .Reset);
}
}

pub const StackIterator = struct {
Expand Down
5 changes: 5 additions & 0 deletions src/Air.zig
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,10 @@ pub const Inst = struct {
/// Uses the `ty_op` field.
addrspace_cast,

/// Saves the error return trace index, if any. Otherwise, returns 0.
/// Uses the `ty_pl` field.
save_err_return_trace_index,

pub fn fromCmpOp(op: std.math.CompareOperator, optimized: bool) Tag {
switch (op) {
.lt => return if (optimized) .cmp_lt_optimized else .cmp_lt,
Expand Down Expand Up @@ -1179,6 +1183,7 @@ pub fn typeOfIndex(air: Air, inst: Air.Inst.Index) Type {
.slice_len,
.ret_addr,
.frame_addr,
.save_err_return_trace_index,
=> return Type.usize,

.wasm_memory_grow => return Type.i32,
Expand Down
Loading