| ... | ... | @@ -242,8 +242,7 @@ pub fn dumpStackTraceFromBase(context: *const ThreadContext) void { |
| 242 | 242 | printSourceAtAddress(debug_info, stderr, it.unwind_state.?.dwarf_context.pc, tty_config) catch return; |
| 243 | 243 | |
| 244 | 244 | while (it.next()) |return_address| { |
| 245 | | if (it.getLastError()) |unwind_error| |
| 246 | | printUnwindError(debug_info, stderr, unwind_error.address, unwind_error.err, tty_config) catch {}; |
| 245 | printLastUnwindError(&it, debug_info, stderr, tty_config); |
| 247 | 246 | |
| 248 | 247 | // On arm64 macOS, the address of the last frame is 0x0 rather than 0x1 as on x86_64 macOS, |
| 249 | 248 | // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid |
| ... | ... | @@ -252,10 +251,7 @@ pub fn dumpStackTraceFromBase(context: *const ThreadContext) void { |
| 252 | 251 | // same behaviour for x86-windows-msvc |
| 253 | 252 | const address = if (return_address == 0) return_address else return_address - 1; |
| 254 | 253 | printSourceAtAddress(debug_info, stderr, address, tty_config) catch return; |
| 255 | | } else { |
| 256 | | if (it.getLastError()) |unwind_error| |
| 257 | | printUnwindError(debug_info, stderr, unwind_error.address, unwind_error.err, tty_config) catch {}; |
| 258 | | } |
| 254 | } else printLastUnwindError(&it, debug_info, stderr, tty_config); |
| 259 | 255 | } |
| 260 | 256 | } |
| 261 | 257 | |
| ... | ... | @@ -734,8 +730,7 @@ pub fn writeCurrentStackTrace( |
| 734 | 730 | defer it.deinit(); |
| 735 | 731 | |
| 736 | 732 | while (it.next()) |return_address| { |
| 737 | | if (it.getLastError()) |unwind_error| |
| 738 | | try printUnwindError(debug_info, out_stream, unwind_error.address, unwind_error.err, tty_config); |
| 733 | printLastUnwindError(&it, debug_info, out_stream, tty_config); |
| 739 | 734 | |
| 740 | 735 | // On arm64 macOS, the address of the last frame is 0x0 rather than 0x1 as on x86_64 macOS, |
| 741 | 736 | // therefore, we do a check for `return_address == 0` before subtracting 1 from it to avoid |
| ... | ... | @@ -744,10 +739,7 @@ pub fn writeCurrentStackTrace( |
| 744 | 739 | // same behaviour for x86-windows-msvc |
| 745 | 740 | const address = if (return_address == 0) return_address else return_address - 1; |
| 746 | 741 | try printSourceAtAddress(debug_info, out_stream, address, tty_config); |
| 747 | | } else { |
| 748 | | if (it.getLastError()) |unwind_error| |
| 749 | | try printUnwindError(debug_info, out_stream, unwind_error.address, unwind_error.err, tty_config); |
| 750 | | } |
| 742 | } else printLastUnwindError(&it, debug_info, out_stream, tty_config); |
| 751 | 743 | } |
| 752 | 744 | |
| 753 | 745 | pub noinline fn walkStackWindows(addresses: []usize, existing_context: ?*const windows.CONTEXT) usize { |
| ... | ... | @@ -885,7 +877,14 @@ fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usiz |
| 885 | 877 | ); |
| 886 | 878 | } |
| 887 | 879 | |
| 888 | | pub fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void { |
| 880 | fn printLastUnwindError(it: *StackIterator, debug_info: *DebugInfo, out_stream: anytype, tty_config: io.tty.Config) void { |
| 881 | if (!have_ucontext) return; |
| 882 | if (it.getLastError()) |unwind_error| { |
| 883 | printUnwindError(debug_info, out_stream, unwind_error.address, unwind_error.err, tty_config) catch {}; |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void { |
| 889 | 888 | const module_name = debug_info.getModuleNameForAddress(address) orelse "???"; |
| 890 | 889 | try tty_config.setColor(out_stream, .dim); |
| 891 | 890 | if (err == error.MissingDebugInfo) { |