authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-06-15 23:51:25+10:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-06-15 23:51:25+10:00
logaf592f0ddd4448e746cf288b674c0199325598d5
tree0f6ec3faebbe5169743ce62a6bf6eb07226ce547
parentce30357532395f46229052b5bcdc5f0a49d2b20d
signaturelock-open Commit is signed but in an unrecognized format.

std: remove std.debug.getStderrStream

Rather than migrate to new 'writer' interface, just remove it

2 files changed, 7 insertions(+), 11 deletions(-)

lib/std/debug.zig+6-10
...@@ -57,14 +57,10 @@ var stderr_mutex = std.Mutex.init();...@@ -57,14 +57,10 @@ var stderr_mutex = std.Mutex.init();
57pub fn warn(comptime fmt: []const u8, args: var) void {57pub fn warn(comptime fmt: []const u8, args: var) void {
58 const held = stderr_mutex.acquire();58 const held = stderr_mutex.acquire();
59 defer held.release();59 defer held.release();
60 const stderr = getStderrStream();60 const stderr = io.getStdErr().writer();
61 nosuspend stderr.print(fmt, args) catch return;61 nosuspend stderr.print(fmt, args) catch return;
62}62}
6363
64pub fn getStderrStream() File.OutStream {
65 return io.getStdErr().outStream();
66}
67
68pub fn getStderrMutex() *std.Mutex {64pub fn getStderrMutex() *std.Mutex {
69 return &stderr_mutex;65 return &stderr_mutex;
70}66}
...@@ -102,7 +98,7 @@ pub fn detectTTYConfig() TTY.Config {...@@ -102,7 +98,7 @@ pub fn detectTTYConfig() TTY.Config {
102/// TODO multithreaded awareness98/// TODO multithreaded awareness
103pub fn dumpCurrentStackTrace(start_addr: ?usize) void {99pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
104 nosuspend {100 nosuspend {
105 const stderr = getStderrStream();101 const stderr = io.getStdErr().writer();
106 if (builtin.strip_debug_info) {102 if (builtin.strip_debug_info) {
107 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;103 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
108 return;104 return;
...@@ -123,7 +119,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void {...@@ -123,7 +119,7 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
123/// TODO multithreaded awareness119/// TODO multithreaded awareness
124pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {120pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {
125 nosuspend {121 nosuspend {
126 const stderr = getStderrStream();122 const stderr = io.getStdErr().writer();
127 if (builtin.strip_debug_info) {123 if (builtin.strip_debug_info) {
128 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;124 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
129 return;125 return;
...@@ -193,7 +189,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace...@@ -193,7 +189,7 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace
193/// TODO multithreaded awareness189/// TODO multithreaded awareness
194pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {190pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {
195 nosuspend {191 nosuspend {
196 const stderr = getStderrStream();192 const stderr = io.getStdErr().writer();
197 if (builtin.strip_debug_info) {193 if (builtin.strip_debug_info) {
198 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;194 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
199 return;195 return;
...@@ -261,7 +257,7 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c...@@ -261,7 +257,7 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
261 const held = panic_mutex.acquire();257 const held = panic_mutex.acquire();
262 defer held.release();258 defer held.release();
263259
264 const stderr = getStderrStream();260 const stderr = io.getStdErr().writer();
265 stderr.print(format ++ "\n", args) catch os.abort();261 stderr.print(format ++ "\n", args) catch os.abort();
266 if (trace) |t| {262 if (trace) |t| {
267 dumpStackTrace(t.*);263 dumpStackTrace(t.*);
...@@ -286,7 +282,7 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c...@@ -286,7 +282,7 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
286 // A panic happened while trying to print a previous panic message,282 // A panic happened while trying to print a previous panic message,
287 // we're still holding the mutex but that's fine as we're going to283 // we're still holding the mutex but that's fine as we're going to
288 // call abort()284 // call abort()
289 const stderr = getStderrStream();285 const stderr = io.getStdErr().writer();
290 stderr.print("Panicked during a panic. Aborting.\n", .{}) catch os.abort();286 stderr.print("Panicked during a panic. Aborting.\n", .{}) catch os.abort();
291 },287 },
292 else => {288 else => {
lib/std/json.zig+1-1
...@@ -1288,7 +1288,7 @@ pub const Value = union(enum) {...@@ -1288,7 +1288,7 @@ pub const Value = union(enum) {
1288 var held = std.debug.getStderrMutex().acquire();1288 var held = std.debug.getStderrMutex().acquire();
1289 defer held.release();1289 defer held.release();
12901290
1291 const stderr = std.debug.getStderrStream();1291 const stderr = io.getStdErr().writer();
1292 std.json.stringify(self, std.json.StringifyOptions{ .whitespace = null }, stderr) catch return;1292 std.json.stringify(self, std.json.StringifyOptions{ .whitespace = null }, stderr) catch return;
1293 }1293 }
1294};1294};