diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-05 20:40:11 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:51 +0100 |
| commit | c2ada49354897f89a2e2030ad1e083a8ee9b7c3b (patch) | |
| tree | 12160c75ce6d7ff7e43212911be88a795a6997e5 /lib/std/builtin.zig | |
| parent | 5709369d059ba107accaadb4b977281e2ba843ed (diff) | |
| download | zig-c2ada49354897f89a2e2030ad1e083a8ee9b7c3b.tar.gz zig-c2ada49354897f89a2e2030ad1e083a8ee9b7c3b.zip | |
replace usages of old std.debug APIs
src/crash_handler.zig is still TODO though, i am planning bigger changes there
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); } }; |
