diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-12 02:12:11 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-12 02:12:11 -0500 |
| commit | 32ea6f54e5f05c4173828c4f4c8ab9965a929120 (patch) | |
| tree | f4c48c5be138070207c19629c08d763c8a6a1325 /std/special/panic.zig | |
| parent | 7ec783876a565662223268a70ba984e0a132b94a (diff) | |
| download | zig-32ea6f54e5f05c4173828c4f4c8ab9965a929120.tar.gz zig-32ea6f54e5f05c4173828c4f4c8ab9965a929120.zip | |
*WIP* proof of concept error return traces
Diffstat (limited to 'std/special/panic.zig')
| -rw-r--r-- | std/special/panic.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/std/special/panic.zig b/std/special/panic.zig index 03c2586739..690c4afa1c 100644 --- a/std/special/panic.zig +++ b/std/special/panic.zig @@ -4,14 +4,20 @@ // have to be added in the compiler. const builtin = @import("builtin"); +const std = @import("std"); -pub coldcc fn panic(msg: []const u8) -> noreturn { +pub coldcc fn panic(msg: []const u8, error_return_trace: ?&builtin.StackTrace) -> noreturn { switch (builtin.os) { // TODO: fix panic in zen. builtin.Os.freestanding, builtin.Os.zen => { while (true) {} }, else => { + if (error_return_trace) |trace| { + std.debug.warn("{}\n", msg); + std.debug.dumpStackTrace(trace); + @import("std").debug.panic(""); + } @import("std").debug.panic("{}", msg); }, } |
