package core:debug/trace

⌘K
Ctrl+K
or
/

    Overview

    A debug stack trace library. Only works when debug symbols are enabled -debug.

    Example:
    import "base:runtime"
    import "core:debug/trace"
    
    import "core:fmt"
    
    global_trace_ctx: trace.Context
    
    debug_trace_assertion_failure_proc :: proc(prefix, message: string, loc := #caller_location) -> ! {
    	runtime.print_caller_location(loc)
    	runtime.print_string(" ")
    	runtime.print_string(prefix)
    	if len(message) > 0 {
    		runtime.print_string(": ")
    		runtime.print_string(message)
    	}
    	runtime.print_byte('\n')
    
    	ctx := &trace_ctx
    	if !trace.in_resolve(ctx) {
    		buf: [64]trace.Frame
    		runtime.print_string("Debug Trace:\n")
    		frames := trace.frames(ctx, 1, buf[:])
    		for f, i in frames {
    			fl := trace.resolve(ctx, f, context.temp_allocator)
    			if fl.loc.file_path == "" && fl.loc.line == 0 {
    				continue
    			}
    			runtime.print_caller_location(fl.loc)
    			runtime.print_string(" - frame ")
    			runtime.print_int(i)
    			runtime.print_byte('\n')
    		}
    	}
    	runtime.trap()
    }
    
    main :: proc() {
    	trace.init(&global_trace_ctx)
    	defer trace.destroy(&global_trace_ctx)
    
    	context.assertion_failure_proc = debug_trace_assertion_failure_proc
    
    	...
    }
    

    Index

    Constants (0)

    This section is empty.

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Context ¶

    Context :: struct {
    	in_resolve: bool,
    	// atomic
    	impl:       _Context,
    }
    Related Procedures With Parameters

    Frame ¶

    Frame :: distinct uintptr
    Related Procedures With Parameters

    Frame_Location ¶

    Frame_Location :: struct {
    	using loc: runtime.Source_Code_Location,
    	allocator: runtime.Allocator,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Constants

    This section is empty.

    Variables

    This section is empty.

    Procedures

    delete_frame_location ¶

    delete_frame_location :: proc(fl: Frame_Location) -> runtime.Allocator_Error {…}

    destroy ¶

    destroy :: proc(ctx: ^Context) -> bool {…}

    frames ¶

    frames :: proc(ctx: ^Context, skip: uint, frames_buffer: []Frame) -> []Frame {…}

    in_resolve ¶

    in_resolve :: proc "contextless" (ctx: ^Context) -> bool {…}

    init ¶

    init :: proc(ctx: ^Context) -> bool {…}

    resolve ¶

    resolve :: proc(ctx: ^Context, frame: Frame, allocator: runtime.Allocator) -> (result: Frame_Location) {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-20 21:10:45.874492100 +0000 UTC