diff options
| author | Cody Tapscott <topolarity@tapscott.me> | 2022-09-25 20:18:15 -0700 |
|---|---|---|
| committer | Cody Tapscott <topolarity@tapscott.me> | 2022-10-21 12:40:33 -0700 |
| commit | a4523a2d4a0fb2b5c660a11aa37718080eebe9d0 (patch) | |
| tree | 2d03ffade98f1d46db5af94eae7be40c998b93e7 /lib/std/debug.zig | |
| parent | d060cbbec75ac7b0204c706e4dfdfb38f1b24dfd (diff) | |
| download | zig-a4523a2d4a0fb2b5c660a11aa37718080eebe9d0.tar.gz zig-a4523a2d4a0fb2b5c660a11aa37718080eebe9d0.zip | |
builtin.zig: Do not overwrite error frames when trace full
Previously, we'd overwrite the errors in a circular buffer. Now that
error return traces are intended to follow a stack discipline, we no
longer have to support the index rolling over. By treating the trace
like a saturating stack, any pop/restore code still behaves correctly
past-the-end of the trace.
As a bonus, this adds a small blurb to let the user know when the trace
saturated and x number of frames were dropped.
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 93216f0058..21b05249a1 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -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 { |
