authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-23 14:06:35-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-26 20:58:29-04:00
loga84826115fa06b8f2da2b3cf0f182c4b75706e2c
tree76f85c33163e77a8dbd186d11d81731aa72b155f
parent1aacfa7186187ed467a5e3189a877493d5c620a1

debug: print unwind errors if they occur on the first iteration, and differentiate between missing info and an actual unwind error in the message


1 files changed, 11 insertions(+), 1 deletions(-)

lib/std/debug.zig+11-1
...@@ -252,6 +252,9 @@ pub fn dumpStackTraceFromBase(context: *const ThreadContext) void {...@@ -252,6 +252,9 @@ pub fn dumpStackTraceFromBase(context: *const ThreadContext) void {
252 // same behaviour for x86-windows-msvc252 // same behaviour for x86-windows-msvc
253 const address = if (return_address == 0) return_address else return_address - 1;253 const address = if (return_address == 0) return_address else return_address - 1;
254 printSourceAtAddress(debug_info, stderr, address, tty_config) catch return;254 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 {};
255 }258 }
256 }259 }
257}260}
...@@ -741,6 +744,9 @@ pub fn writeCurrentStackTrace(...@@ -741,6 +744,9 @@ pub fn writeCurrentStackTrace(
741 // same behaviour for x86-windows-msvc744 // same behaviour for x86-windows-msvc
742 const address = if (return_address == 0) return_address else return_address - 1;745 const address = if (return_address == 0) return_address else return_address - 1;
743 try printSourceAtAddress(debug_info, out_stream, address, tty_config);746 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);
744 }750 }
745}751}
746752
...@@ -882,7 +888,11 @@ fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usiz...@@ -882,7 +888,11 @@ fn printUnknownSource(debug_info: *DebugInfo, out_stream: anytype, address: usiz
882pub fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void {888pub fn printUnwindError(debug_info: *DebugInfo, out_stream: anytype, address: usize, err: UnwindError, tty_config: io.tty.Config) !void {
883 const module_name = debug_info.getModuleNameForAddress(address) orelse "???";889 const module_name = debug_info.getModuleNameForAddress(address) orelse "???";
884 try tty_config.setColor(out_stream, .dim);890 try tty_config.setColor(out_stream, .dim);
885 try out_stream.print("Unwind information for `{s}:0x{x}` was not available ({}), trace may be incomplete\n\n", .{ module_name, address, err });891 if (err == error.MissingDebugInfo) {
892 try out_stream.print("Unwind information for `{s}:0x{x}` was not available, trace may be incomplete\n\n", .{ module_name, address });
893 } else {
894 try out_stream.print("Unwind error at address `{s}:0x{x}` ({}), trace may be incomplete\n\n", .{ module_name, address, err });
895 }
886 try tty_config.setColor(out_stream, .reset);896 try tty_config.setColor(out_stream, .reset);
887}897}
888898