| ... | ... | @@ -678,6 +678,12 @@ pub fn writeCurrentStackTrace(options: StackUnwindOptions, writer: *Writer, tty_ |
| 678 | 678 | tty_config.setColor(writer, .reset) catch {}; |
| 679 | 679 | return; |
| 680 | 680 | }, |
| 681 | error.CannotUnwindFromContext => { |
| 682 | tty_config.setColor(writer, .dim) catch {}; |
| 683 | try writer.print("Cannot print stack trace: context unwind unavailable for target\n", .{}); |
| 684 | tty_config.setColor(writer, .reset) catch {}; |
| 685 | return; |
| 686 | }, |
| 681 | 687 | }; |
| 682 | 688 | defer it.deinit(); |
| 683 | 689 | if (!it.stratOk(options.allow_unsafe_unwind)) { |
| ... | ... | @@ -787,7 +793,7 @@ const StackIterator = union(enum) { |
| 787 | 793 | /// It is important that this function is marked `inline` so that it can safely use |
| 788 | 794 | /// `@frameAddress` and `getContext` as the caller's stack frame and our own are one |
| 789 | 795 | /// and the same. |
| 790 | | inline fn init(context_opt: ?ThreadContextPtr, context_buf: *ThreadContextBuf) error{OutOfMemory}!StackIterator { |
| 796 | inline fn init(context_opt: ?ThreadContextPtr, context_buf: *ThreadContextBuf) error{ OutOfMemory, CannotUnwindFromContext }!StackIterator { |
| 791 | 797 | if (builtin.cpu.arch.isSPARC()) { |
| 792 | 798 | // Flush all the register windows on stack. |
| 793 | 799 | if (builtin.cpu.has(.sparc, .v9)) { |
| ... | ... | @@ -797,11 +803,12 @@ const StackIterator = union(enum) { |
| 797 | 803 | } |
| 798 | 804 | } |
| 799 | 805 | if (context_opt) |context| { |
| 806 | if (!SelfInfo.supports_unwinding) return error.CannotUnwindFromContext; |
| 800 | 807 | context_buf.* = context.*; |
| 801 | 808 | relocateContext(context_buf); |
| 802 | 809 | return .{ .di = try .init(context_buf, getDebugInfoAllocator()) }; |
| 803 | 810 | } |
| 804 | | if (getContext(context_buf)) { |
| 811 | if (SelfInfo.supports_unwinding and getContext(context_buf)) { |
| 805 | 812 | return .{ .di = try .init(context_buf, getDebugInfoAllocator()) }; |
| 806 | 813 | } |
| 807 | 814 | return .{ .fp = @frameAddress() }; |