2017-09-30 15:58:41 -07:00
|
|
|
// This file is the default panic handler if the root source file does not
|
|
|
|
// have a `pub fn panic`.
|
|
|
|
// If this file wants to import other files *by name*, support for that would
|
|
|
|
// have to be added in the compiler.
|
|
|
|
|
|
|
|
const builtin = @import("builtin");
|
2018-01-11 23:12:11 -08:00
|
|
|
const std = @import("std");
|
2017-09-30 15:58:41 -07:00
|
|
|
|
2018-05-31 07:56:59 -07:00
|
|
|
pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
|
2018-01-22 19:24:07 -08:00
|
|
|
@setCold(true);
|
2018-01-07 01:43:08 -08:00
|
|
|
switch (builtin.os) {
|
|
|
|
// TODO: fix panic in zen.
|
|
|
|
builtin.Os.freestanding, builtin.Os.zen => {
|
|
|
|
while (true) {}
|
|
|
|
},
|
|
|
|
else => {
|
2018-03-09 19:21:13 -08:00
|
|
|
const first_trace_addr = @ptrToInt(@returnAddress());
|
|
|
|
std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", msg);
|
2018-01-07 01:43:08 -08:00
|
|
|
},
|
2017-09-30 15:58:41 -07:00
|
|
|
}
|
|
|
|
}
|