Function writeStackTrace [src]

Prototype

pub fn writeStackTrace( stack_trace: std.builtin.StackTrace, out_stream: anytype, debug_info: *SelfInfo, tty_config: io.tty.Config, ) !void

Parameters

stack_trace: std.builtin.StackTracedebug_info: *SelfInfotty_config: io.tty.Config

Source

pub fn writeStackTrace( stack_trace: std.builtin.StackTrace, out_stream: anytype, debug_info: *SelfInfo, tty_config: io.tty.Config, ) !void { if (builtin.strip_debug_info) return error.MissingDebugInfo; var frame_index: usize = 0; var frames_left: usize = @min(stack_trace.index, stack_trace.instruction_addresses.len); while (frames_left != 0) : ({ frames_left -= 1; frame_index = (frame_index + 1) % stack_trace.instruction_addresses.len; }) { 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) catch {}; try out_stream.print("({d} additional stack frames skipped...)\n", .{dropped_frames}); tty_config.setColor(out_stream, .reset) catch {}; } }