| ... | ... | @@ -105,11 +105,15 @@ pub fn getSelfDebugInfo() !*DebugInfo { |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /// Tries to print a hexadecimal view of the bytes, unbuffered, and ignores any error returned. |
| 108 | | pub fn hexdump(bytes: []const u8) void { |
| 109 | | hexdump_internal(bytes) catch {}; |
| 108 | /// Obtains the stderr mutex while dumping. |
| 109 | pub fn dump_hex(bytes: []const u8) void { |
| 110 | stderr_mutex.lock(); |
| 111 | defer stderr_mutex.unlock(); |
| 112 | dump_hex_fallible(bytes) catch {}; |
| 110 | 113 | } |
| 111 | 114 | |
| 112 | | fn hexdump_internal(bytes: []const u8) !void { |
| 115 | /// Prints a hexadecimal view of the bytes, unbuffered, returning any error that occurs. |
| 116 | pub fn dump_hex_fallible(bytes: []const u8) !void { |
| 113 | 117 | const stderr = std.io.getStdErr(); |
| 114 | 118 | const ttyconf = std.io.tty.detectConfig(stderr); |
| 115 | 119 | const writer = stderr.writer(); |
| ... | ... | @@ -140,7 +144,7 @@ fn hexdump_internal(bytes: []const u8) !void { |
| 140 | 144 | if (std.ascii.isPrint(byte)) { |
| 141 | 145 | try writer.writeByte(byte); |
| 142 | 146 | } else { |
| 143 | | // TODO: remove this `if` when https://github.com/ziglang/zig/issues/7600 is fixed |
| 147 | // Related: https://github.com/ziglang/zig/issues/7600 |
| 144 | 148 | if (ttyconf == .windows_api) { |
| 145 | 149 | try writer.writeByte('.'); |
| 146 | 150 | continue; |
| ... | ... | @@ -2831,3 +2835,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize |
| 2831 | 2835 | } |
| 2832 | 2836 | }; |
| 2833 | 2837 | } |
| 2838 | |
| 2839 | test { |
| 2840 | _ = &dump_hex; |
| 2841 | } |