diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-12-08 21:57:46 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-23 22:15:08 -0800 |
| commit | 90f7259ef17e8e07c2c3f71bea65d103cfe52c07 (patch) | |
| tree | c7d4025d746c265dd5907b81295b86d6f67eb80c /lib/std/debug.zig | |
| parent | bee8005fe6817ade9191de0493888b14cdbcac31 (diff) | |
| download | zig-90f7259ef17e8e07c2c3f71bea65d103cfe52c07.tar.gz zig-90f7259ef17e8e07c2c3f71bea65d103cfe52c07.zip | |
std.Progress: use a global static Io instance
This decision should be audited and discussed.
Some factors:
* Passing an Io instance into start.
* Avoiding reference to global static instance if it won't be used, so
that it doesn't bloat the executable.
* Being able to use std.debug.print, and related functionality when
debugging std.Io instances and std.Progress.
Diffstat (limited to 'lib/std/debug.zig')
| -rw-r--r-- | lib/std/debug.zig | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 8f1cd50e8e..6ffa254271 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -286,13 +286,12 @@ pub fn unlockStdErr() void { pub fn lockStderrWriter(buffer: []u8) struct { *Writer, tty.Config } { const global = struct { var conf: ?tty.Config = null; - var single_threaded_io: Io.Threaded = .init_single_threaded; }; - const io = global.single_threaded_io.io(); const w = std.Progress.lockStderrWriter(buffer); + const file_writer: *File.Writer = @fieldParentPtr("interface", w); // The stderr lock also locks access to `global.conf`. if (global.conf == null) { - global.conf = .detect(io, .stderr()); + global.conf = .detect(file_writer.io, .stderr()); } return .{ w, global.conf.? }; } @@ -619,13 +618,15 @@ pub const StackUnwindOptions = struct { /// /// See `writeCurrentStackTrace` to immediately print the trace instead of capturing it. pub noinline fn captureCurrentStackTrace(options: StackUnwindOptions, addr_buf: []usize) StackTrace { - var threaded: Io.Threaded = .init_single_threaded; - const io = threaded.ioBasic(); const empty_trace: StackTrace = .{ .index = 0, .instruction_addresses = &.{} }; if (!std.options.allow_stack_tracing) return empty_trace; var it: StackIterator = .init(options.context); defer it.deinit(); if (!it.stratOk(options.allow_unsafe_unwind)) return empty_trace; + + var threaded: Io.Threaded = .init_single_threaded; + const io = threaded.ioBasic(); + var total_frames: usize = 0; var index: usize = 0; var wait_for = options.first_address; |
