Function panicExtra [src]

Equivalent to @panic but with a formatted message, and with an explicitly provided return address.

Prototype

pub fn panicExtra( ret_addr: ?usize, comptime format: []const u8, args: anytype, ) noreturn

Parameters

ret_addr: ?usizeformat: []const u8

Source

pub 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; // 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 = std.fmt.bufPrint(buf[0..size], format, args) catch |err| switch (err) { error.NoSpaceLeft => blk: { @memcpy(buf[size..], trunc_msg); break :blk &buf; }, }; std.builtin.panic.call(msg, ret_addr); }