Functions

fn assert(ok: bool) void

This function invokes undefined behavior when ok is false. In Debug and Rel…

This function invokes undefined behavior when ok is false. In Debug and ReleaseSafe modes, calls to this function are always generated, and the unreachable statement triggers a panic. In ReleaseFast and ReleaseSmall modes, calls to this function are optimized away, and in fact the optimizer is able to use the assertion in its heuristics. Inside a test block, it is best to use the std.testing module rather than this function, because this function may not detect a test failure in ReleaseFast and ReleaseSmall mode. Outside of a test block, this assert function is the correct function to use.

fn attachSegfaultHandler() void

Attaches a global SIGSEGV handler which calls @panic(“segmentation fault”);

fn captureStackTrace(first_address: ?usize, stack_trace: *std.builtin.StackTrace) void

Returns a slice with the same pointer as addresses, with a potentially smaller l…

Returns a slice with the same pointer as addresses, with a potentially smaller len. On Windows, when first_address is not null, we ask for at least 32 stack frames, and then try to find the first address. If addresses.len is more than 32, we capture that many stack frames exactly, and then look for the first address, chopping off the irrelevant frames and shifting so that the returned addresses pointer equals the passed in addresses pointer.

fn copyContext(source: *const ThreadContext, dest: *ThreadContext) void

Copies one context to another, updating any internal pointers

fn dumpCurrentStackTrace(start_addr: ?usize) void

Tries to print the current stack trace to stderr, unbuffered, and ignores any er…

Tries to print the current stack trace to stderr, unbuffered, and ignores any error returned. TODO multithreaded awareness

fn dumpStackPointerAddr(prefix: []const u8) void

No documentation provided.

fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void

Tries to print a stack trace to stderr, unbuffered, and ignores any error return…

Tries to print a stack trace to stderr, unbuffered, and ignores any error returned. TODO multithreaded awareness

fn dumpStackTraceFromBase(context: *const ThreadContext) void

Tries to print the stack trace starting from the supplied base pointer to stderr…

Tries to print the stack trace starting from the supplied base pointer to stderr, unbuffered, and ignores any error returned. TODO multithreaded awareness

inline fn getContext(context: *ThreadContext) bool

Capture the current context. The register values in the context will reflect the…

Capture the current context. The register values in the context will reflect the state after the platform getcontext function returns.

It is valid to call this if the platform doesn’t have context capturing support, in that case false will be returned.

fn getSelfDebugInfo() !*DebugInfo

No documentation provided.

fn getStderrMutex() *std.Thread.Mutex

No documentation provided.

fn maybeEnableSegfaultHandler() void

No documentation provided.

fn openSelfDebugInfo(allocator: mem.Allocator) OpenSelfDebugInfoError!DebugInfo

No documentation provided.

fn panic(comptime format: []const u8, args: anytype) noreturn

No documentation provided.

fn panicExtra(trace: ?*std.builtin.StackTrace, ret_addr: ?usize, comptime format: []const u8, args: anytype) noreturn

panicExtra is useful when you want to print out an @errorReturnTrace and al…

panicExtra is useful when you want to print out an @errorReturnTrace and also print out some values.

fn panicImpl(trace: ?*const std.builtin.StackTrace, first_trace_addr: ?usize, msg: []const u8) noreturn

No documentation provided.

fn print(comptime fmt: []const u8, args: anytype) void

Print to stderr, unbuffered, and silently returning on failure. Intended for us…

Print to stderr, unbuffered, and silently returning on failure. Intended for use in “printf debugging.” Use std.log functions for proper logging.

fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: io.tty.Config) !void

No documentation provided.

fn readElfDebugInfo(allocator: mem.Allocator, elf_filename: ?[]const u8, build_id: ?[]const u8, expected_crc: ?u32, parent_sections: *DW.DwarfInfo.SectionArray, parent_mapped_mem: ?[]const align(mem.page_size) u8) !ModuleDebugInfo

Reads debug info from an ELF file, or the current binary if none in specified. …

Reads debug info from an ELF file, or the current binary if none in specified. If the required sections aren’t present but a reference to external debug info is, then this this function will recurse to attempt to load the debug sections from an external file.

fn relocateContext(context: *ThreadContext) void

Updates any internal pointers in the context to reflect its current location

fn updateSegfaultHandler(act: ?*const os.Sigaction) error{OperationNotSupported}!void

No documentation provided.

fn walkStackWindows(addresses: []usize, existing_context: ?*const windows.T) usize

No documentation provided.

fn writeCurrentStackTrace(out_stream: anytype, debug_info: *DebugInfo, tty_config: io.tty.Config, start_addr: ?usize) !void

No documentation provided.

fn writeStackTrace(stack_trace: std.builtin.StackTrace, out_stream: anytype, allocator: mem.Allocator, debug_info: *DebugInfo, tty_config: io.tty.Config) !void

No documentation provided.

fn writeStackTraceWindows(out_stream: anytype, debug_info: *DebugInfo, tty_config: io.tty.Config, context: *const windows.T, start_addr: ?usize) !void

No documentation provided.

Values

ModuleDebugInfo
type
OpenSelfDebugInfoError
type
ThreadContext
type

Platform-specific thread state. This contains register state, and on some platfo…

Trace
undefined

This API helps you track where a value originated and where it was mutated, or …

UnwindError
type
default_enable_segfault_handler
bool
have_getcontext
bool
have_segfault_handling_support
type

Whether or not the current target can print useful debug information when a segf…

have_ucontext
bool
runtime_safety
type
sys_can_stack_trace
type