| ... | @@ -57,14 +57,10 @@ var stderr_mutex = std.Mutex.init(); | ... | @@ -57,14 +57,10 @@ var stderr_mutex = std.Mutex.init(); |
| 57 | pub fn warn(comptime fmt: []const u8, args: var) void { | 57 | pub 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 | } |
| 63 | | 63 | |
| 64 | pub fn getStderrStream() File.OutStream { | | |
| 65 | return io.getStdErr().outStream(); | | |
| 66 | } | | |
| 67 | | | |
| 68 | pub fn getStderrMutex() *std.Mutex { | 64 | pub 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 awareness | 98 | /// TODO multithreaded awareness |
| 103 | pub fn dumpCurrentStackTrace(start_addr: ?usize) void { | 99 | pub 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 awareness | 119 | /// TODO multithreaded awareness |
| 124 | pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { | 120 | pub 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 awareness | 189 | /// TODO multithreaded awareness |
| 194 | pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { | 190 | pub 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(); |
| 263 | | 259 | |
| 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 to | 283 | // 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 => { |