diff options
Diffstat (limited to 'lib/std/builtin.zig')
| -rw-r--r-- | lib/std/builtin.zig | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 2504b8fe2f..a3f3e791e6 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -38,20 +38,17 @@ pub const StackTrace = struct { index: usize, instruction_addresses: []usize, - pub fn format(self: StackTrace, writer: *std.Io.Writer) std.Io.Writer.Error!void { + pub fn format(st: *const StackTrace, writer: *std.Io.Writer) std.Io.Writer.Error!void { // TODO: re-evaluate whether to use format() methods at all. // Until then, avoid an error when using GeneralPurposeAllocator with WebAssembly // where it tries to call detectTTYConfig here. if (builtin.os.tag == .freestanding) return; - const debug_info = std.debug.getSelfDebugInfo() catch |err| { - return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}); - }; - const tty_config = std.Io.tty.detectConfig(std.fs.File.stderr()); + // TODO: why on earth are we using stderr's ttyconfig? + // If we want colored output, we should just make a formatter out of `writeStackTrace`. + const tty_config = std.Io.tty.detectConfig(.stderr()); try writer.writeAll("\n"); - std.debug.writeStackTrace(self, writer, debug_info, tty_config) catch |err| { - try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); - }; + try std.debug.writeStackTrace(st, writer, tty_config); } }; |
