Skip to content
FormatStackTrace

FormatStackTrace

Description

Resolve each frame to module!symbol+offset and append a multi- line trace to out. A fresh SymbolResolver is created internally for each call — convenient for one-off uses, but if you format many traces in a loop, share a resolver via FormatStackTraceWith.

Parameters

Name Direction Description
out out Str to append to.
frames in Frames captured by CaptureStackTrace.
count in Number of valid frames.
alloc in Allocator backing the resolver and any scratch.

Success

Output appended.

Failure

Function does not fail; unresolved frames emit as #N 0x<ip>.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        Str rendered = StrInit(alloc_base);
        FormatStackTrace(&rendered, frames, n, alloc_base);
    
        // We expect both helper names to appear in the rendered trace.
    }
    
    void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        (void)alloc;
        if (!out || !frames)
    }
    
    void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
        }
        Str rendered = StrInit(meta);
        FormatStackTrace(&rendered, frames, count, meta);
        LOG_ERROR("    {} trace:\n{}", label, rendered);
        StrDeinit(&rendered);
            StrWriteFmt(out, "leaked {x} ({} bytes)\n", (u64)(uintptr_t)user_p, (u64)rec->requested_size);
            if (rec->alloc_trace_n) {
                FormatStackTrace(out, rec->alloc_trace, rec->alloc_trace_n, self->meta);
            }
        }
Last updated on