diff options
| author | kcbanner <kcbanner@gmail.com> | 2023-07-23 14:06:35 -0400 |
|---|---|---|
| committer | kcbanner <kcbanner@gmail.com> | 2023-07-26 20:58:29 -0400 |
| commit | a84826115fa06b8f2da2b3cf0f182c4b75706e2c (patch) | |
| tree | 76f85c33163e77a8dbd186d11d81731aa72b155f | |
| parent | 1aacfa7186187ed467a5e3189a877493d5c620a1 (diff) | |
| download | zig-a84826115fa06b8f2da2b3cf0f182c4b75706e2c.tar.gz zig-a84826115fa06b8f2da2b3cf0f182c4b75706e2c.zip | |
debug: print unwind errors if they occur on the first iteration, and differentiate between missing info and an actual unwind error in the message
| -rw-r--r-- | lib/std/debug.zig | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 948a76c2df..05657a2fbf 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -252,6 +252,9 @@ pub fn dumpStackTraceFromBase(context: *const ThreadContext) void { // same behaviour for x86-windows-msvc const address = if (return_address == 0) return_address else return_address - 1; printSourceAtAddress(debug_info, stderr, address, tty_config) catch return; + } else { + if (it.getLastError()) |unwind_error| + printUnwindError(debug_info, stderr, unwind_error.address, unwind_error.err, tty_config) catch {}; } } } @@ -741,6 +744,9 @@ pub fn writeCurrentStackTrace( // same behaviour for x86-windows-msvc const address = if (return_address == 0) return_address else return_address - 1; try printSourceAtAddress(debug_info, out_stream, address, tty_config); + } else { + if (it.getLastError()) |unwind_error| + try printUnwindError(debug_info, out_stream, unwind_error.address, unwind_error.err, tty_config); } } @@ -882,7 +888,11 @@ fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usiz pub fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void { const module_name = debug_info.getModuleNameForAddress(address) orelse "???"; try tty_config.setColor(out_stream, .dim); - try out_stream.print("Unwind information for `{s}:0x{x}` was not available ({}), trace may be incomplete\n\n", .{ module_name, address, err }); + if (err == error.MissingDebugInfo) { + try out_stream.print("Unwind information for `{s}:0x{x}` was not available, trace may be incomplete\n\n", .{ module_name, address }); + } else { + try out_stream.print("Unwind error at address `{s}:0x{x}` ({}), trace may be incomplete\n\n", .{ module_name, address, err }); + } try tty_config.setColor(out_stream, .reset); } |
