Skip to content

StackFrame

Description

A single captured stack frame. Just the IP — symbol resolution happens later in FormatStackTrace.

Usage example (Cross-references)

Usage examples (Cross-references)
    // Named helpers so we can verify a specific symbol shows up in the
    // captured trace.
    static __attribute__((noinline)) size bt_capture_with_helper(StackFrame *frames, size max) {
        return CaptureStackTrace(frames, max, 0);
    }
    }
    
    static __attribute__((noinline)) size bt_capture_outer(StackFrame *frames, size max) {
        return bt_capture_with_helper(frames, max);
    }
    
    bool test_backtrace_capture_non_empty(void) {
        StackFrame frames[32];
        size       n = bt_capture_outer(frames, 32);
        return n >= 2 && n <= 32; // at least helper + outer
        Allocator       *alloc_base = ALLOCATOR_OF(&alloc);
    
        StackFrame frames[32];
        size       n = bt_capture_outer(frames, 32);
        }
    
        StackFrame frames[16];
        size       n = bt_capture_outer(frames, 16);
    }
    
    size CaptureStackTrace(StackFrame *out, size max_frames, size skip_frames) {
        if (!out || max_frames == 0)
            return 0;
    }
    
    void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        (void)alloc;
        if (!out || !frames)
    };
    
    size CaptureStackTrace(StackFrame *out, size max_frames, size skip_frames) {
        if (!out || max_frames == 0) {
            return 0;
    }
    
    void FormatStackTraceWith(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver) {
        if (!out || !frames || !resolver)
            return;
    }
    
    void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
        if (!out || !frames || !alloc)
            return;
        u32        free_trace_n;
        bool       freed;
        StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        StackFrame free_trace[DEBUG_ALLOCATOR_MAX_TRACE];
    } DebugRecord;
        bool       freed;
        StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        StackFrame free_trace[DEBUG_ALLOCATOR_MAX_TRACE];
    } DebugRecord;
    }
    
    static void debug_emit_trace(const StackFrame *frames, size count, const char *label, Allocator *meta) {
        if (!count) {
            LOG_ERROR("    {} trace: (none captured)", label);
    typedef struct StackFrame {
        void *ip;
    } StackFrame;
    
    ///
    /// TAGS: Sys, Backtrace, Unwind
    ///
    size CaptureStackTrace(StackFrame *out, size max_frames, size skip_frames);
    
    ///
    /// TAGS: Sys, Backtrace, Format
    ///
    void FormatStackTrace(Str *out, const StackFrame *frames, size count, Allocator *alloc);
    
    #if MISRA_HAVE_SYS_SYMRESOLVE
    /// TAGS: Sys, Backtrace, Format
    ///
    void FormatStackTraceWith(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver);
    #endif
Last updated on