| ... | @@ -308,6 +308,9 @@ pub fn unlockStderr() void { | ... | @@ -308,6 +308,9 @@ pub fn unlockStderr() void { |
| 308 | /// Alternatively, use the higher-level `std.log` or `Io.lockStderr` to | 308 | /// Alternatively, use the higher-level `std.log` or `Io.lockStderr` to |
| 309 | /// integrate with the application's chosen `Io` implementation. | 309 | /// integrate with the application's chosen `Io` implementation. |
| 310 | pub fn print(comptime fmt: []const u8, args: anytype) void { | 310 | pub fn print(comptime fmt: []const u8, args: anytype) void { |
| | 311 | const io = std.Options.debug_io; |
| | 312 | const prev = io.swapCancelProtection(.blocked); |
| | 313 | defer _ = io.swapCancelProtection(prev); |
| 311 | var buffer: [64]u8 = undefined; | 314 | var buffer: [64]u8 = undefined; |
| 312 | const stderr = lockStderr(&buffer); | 315 | const stderr = lockStderr(&buffer); |
| 313 | defer unlockStderr(); | 316 | defer unlockStderr(); |
| ... | @@ -326,6 +329,9 @@ pub inline fn getSelfDebugInfo() !*SelfInfo { | ... | @@ -326,6 +329,9 @@ pub inline fn getSelfDebugInfo() !*SelfInfo { |
| 326 | /// Tries to print a hexadecimal view of the bytes, unbuffered, and ignores any error returned. | 329 | /// Tries to print a hexadecimal view of the bytes, unbuffered, and ignores any error returned. |
| 327 | /// Obtains the stderr mutex while dumping. | 330 | /// Obtains the stderr mutex while dumping. |
| 328 | pub fn dumpHex(bytes: []const u8) void { | 331 | pub fn dumpHex(bytes: []const u8) void { |
| | 332 | const io = std.Options.debug_io; |
| | 333 | const prev = io.swapCancelProtection(.blocked); |
| | 334 | defer _ = io.swapCancelProtection(prev); |
| 329 | const stderr = lockStderr(&.{}).terminal(); | 335 | const stderr = lockStderr(&.{}).terminal(); |
| 330 | defer unlockStderr(); | 336 | defer unlockStderr(); |
| 331 | dumpHexFallible(stderr, bytes) catch {}; | 337 | dumpHexFallible(stderr, bytes) catch {}; |
| ... | @@ -789,6 +795,9 @@ pub noinline fn writeCurrentStackTrace(options: StackUnwindOptions, t: Io.Termin | ... | @@ -789,6 +795,9 @@ pub noinline fn writeCurrentStackTrace(options: StackUnwindOptions, t: Io.Termin |
| 789 | } | 795 | } |
| 790 | /// A thin wrapper around `writeCurrentStackTrace` which writes to stderr and ignores write errors. | 796 | /// A thin wrapper around `writeCurrentStackTrace` which writes to stderr and ignores write errors. |
| 791 | pub fn dumpCurrentStackTrace(options: StackUnwindOptions) void { | 797 | pub fn dumpCurrentStackTrace(options: StackUnwindOptions) void { |
| | 798 | const io = std.Options.debug_io; |
| | 799 | const prev = io.swapCancelProtection(.blocked); |
| | 800 | defer _ = io.swapCancelProtection(prev); |
| 792 | const stderr = lockStderr(&.{}).terminal(); | 801 | const stderr = lockStderr(&.{}).terminal(); |
| 793 | defer unlockStderr(); | 802 | defer unlockStderr(); |
| 794 | writeCurrentStackTrace(.{ | 803 | writeCurrentStackTrace(.{ |
| ... | @@ -879,6 +888,9 @@ fn writeTrace( | ... | @@ -879,6 +888,9 @@ fn writeTrace( |
| 879 | } | 888 | } |
| 880 | /// A thin wrapper around `writeStackTrace` which writes to stderr and ignores write errors. | 889 | /// A thin wrapper around `writeStackTrace` which writes to stderr and ignores write errors. |
| 881 | pub fn dumpStackTrace(st: *const StackTrace) void { | 890 | pub fn dumpStackTrace(st: *const StackTrace) void { |
| | 891 | const io = std.Options.debug_io; |
| | 892 | const prev = io.swapCancelProtection(.blocked); |
| | 893 | defer _ = io.swapCancelProtection(prev); |
| 882 | const stderr = lockStderr(&.{}).terminal(); | 894 | const stderr = lockStderr(&.{}).terminal(); |
| 883 | defer unlockStderr(); | 895 | defer unlockStderr(); |
| 884 | writeStackTrace(st, stderr) catch |err| switch (err) { | 896 | writeStackTrace(st, stderr) catch |err| switch (err) { |
| ... | @@ -888,6 +900,9 @@ pub fn dumpStackTrace(st: *const StackTrace) void { | ... | @@ -888,6 +900,9 @@ pub fn dumpStackTrace(st: *const StackTrace) void { |
| 888 | | 900 | |
| 889 | /// A thin wrapper around `writeErrorReturnTrace` which writes to stderr and ignores write errors. | 901 | /// A thin wrapper around `writeErrorReturnTrace` which writes to stderr and ignores write errors. |
| 890 | pub fn dumpErrorReturnTrace(et: *const std.builtin.StackTrace) void { | 902 | pub fn dumpErrorReturnTrace(et: *const std.builtin.StackTrace) void { |
| | 903 | const io = std.Options.debug_io; |
| | 904 | const prev = io.swapCancelProtection(.blocked); |
| | 905 | defer _ = io.swapCancelProtection(prev); |
| 891 | const stderr = lockStderr(&.{}).terminal(); | 906 | const stderr = lockStderr(&.{}).terminal(); |
| 892 | defer unlockStderr(); | 907 | defer unlockStderr(); |
| 893 | writeErrorReturnTrace(et, stderr) catch |err| switch (err) { | 908 | writeErrorReturnTrace(et, stderr) catch |err| switch (err) { |