| ... | @@ -678,6 +678,12 @@ pub fn writeCurrentStackTrace(options: StackUnwindOptions, writer: *Writer, tty_ | ... | @@ -678,6 +678,12 @@ pub fn writeCurrentStackTrace(options: StackUnwindOptions, writer: *Writer, tty_ |
| 678 | tty_config.setColor(writer, .reset) catch {}; | 678 | tty_config.setColor(writer, .reset) catch {}; |
| 679 | return; | 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 | defer it.deinit(); | 688 | defer it.deinit(); |
| 683 | if (!it.stratOk(options.allow_unsafe_unwind)) { | 689 | if (!it.stratOk(options.allow_unsafe_unwind)) { |
| ... | @@ -787,7 +793,7 @@ const StackIterator = union(enum) { | ... | @@ -787,7 +793,7 @@ const StackIterator = union(enum) { |
| 787 | /// It is important that this function is marked `inline` so that it can safely use | 793 | /// It is important that this function is marked `inline` so that it can safely use |
| 788 | /// `@frameAddress` and `getContext` as the caller's stack frame and our own are one | 794 | /// `@frameAddress` and `getContext` as the caller's stack frame and our own are one |
| 789 | /// and the same. | 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 | if (builtin.cpu.arch.isSPARC()) { | 797 | if (builtin.cpu.arch.isSPARC()) { |
| 792 | // Flush all the register windows on stack. | 798 | // Flush all the register windows on stack. |
| 793 | if (builtin.cpu.has(.sparc, .v9)) { | 799 | if (builtin.cpu.has(.sparc, .v9)) { |
| ... | @@ -797,11 +803,12 @@ const StackIterator = union(enum) { | ... | @@ -797,11 +803,12 @@ const StackIterator = union(enum) { |
| 797 | } | 803 | } |
| 798 | } | 804 | } |
| 799 | if (context_opt) |context| { | 805 | if (context_opt) |context| { |
| | 806 | if (!SelfInfo.supports_unwinding) return error.CannotUnwindFromContext; |
| 800 | context_buf.* = context.*; | 807 | context_buf.* = context.*; |
| 801 | relocateContext(context_buf); | 808 | relocateContext(context_buf); |
| 802 | return .{ .di = try .init(context_buf, getDebugInfoAllocator()) }; | 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 | return .{ .di = try .init(context_buf, getDebugInfoAllocator()) }; | 812 | return .{ .di = try .init(context_buf, getDebugInfoAllocator()) }; |
| 806 | } | 813 | } |
| 807 | return .{ .fp = @frameAddress() }; | 814 | return .{ .fp = @frameAddress() }; |