pub fn panicExtra(
ret_addr: ?usize,
comptime format: []const u8,
args: anytype,
) noreturn ret_addr: ?usizeformat: []const u8args467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486pub fn panicExtra(
ret_addr: ?usize,
comptime format: []const u8,
args: anytype,
) noreturn {
@branchHint(.cold);
const size = 0x1000;
const trunc_msg = "(msg truncated)";
var buf: [size + trunc_msg.len]u8 = undefined;
var bw: Writer = .fixed(buf[0..size]);
// a minor annoyance with this is that it will result in the NoSpaceLeft
// error being part of the @panic stack trace (but that error should
// only happen rarely)
const msg = if (bw.print(format, args)) |_| bw.buffered() else |_| blk: {
@memcpy(buf[size..], trunc_msg);
break :blk &buf;
};
std.builtin.panic.call(msg, ret_addr);
}
Equivalent to
@panicbut with a formatted message and an explicitly provided return address which will be the first address in the stack trace.