Skip to content

DebugRecord

Description

Live-allocation bookkeeping record. Stored in the embedded live map keyed by pointer.

Usage example (Cross-references)

Usage examples (Cross-references)
            u32        alloc_trace_n;
            StackFrame alloc_trace[DEBUG_ALLOCATOR_MAX_TRACE];
        } DebugRecord;
    
        typedef Map(void *, DebugRecord) DebugRecordMap;
        } DebugRecord;
    
        typedef Map(void *, DebugRecord) DebugRecordMap;
    
        ///
            debug_write_canary((u8 *)user_p + bytes, canary);
    
        DebugRecord rec;
        MemSet(&rec, 0, sizeof(rec));
        rec.requested_size = bytes;
            return 0;
    
        DebugRecord *live_rec = MapGetFirstPtr(&self->live, ptr);
    
        if (!live_rec) {
        // the copy. If ptr is not in the live map, forward to deallocate
        // which emits the double-free / foreign-ptr diagnostic and aborts.
        DebugRecord *rec = MapGetFirstPtr(&self->live, ptr);
        if (!rec) {
            debug_allocator_deallocate(self, ptr); // aborts
        // to DebugAllocator with no public accessor; reach in to confirm the
        // alloc-trace was captured.
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL) && (rec->alloc_trace_n > 0);
    
        // intentional bypass: live map / freed Vec are internal, no accessor.
        DebugRecord *rec    = MapGetFirstPtr(&dbg.live, p);
        u32          live_n = ok ? rec->alloc_trace_n : 0;
        ok                  = ok && (live_n > 0) && (live_n <= DEBUG_ALLOCATOR_MAX_TRACE);
        bool  ok = (p != NULL);
    
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        u32          n   = ok ? rec->alloc_trace_n : 0;
        StackFrame   snapshot[DEBUG_ALLOCATOR_MAX_TRACE];
        bool  ok = (p != NULL);
    
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL);
        ok               = ok && (rec->alloc_trace_n > 0);
        bool  ok = (p != NULL);
    
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL);
        ok               = ok && (rec->alloc_trace_n > 0);
        bool  ok = (p != NULL);
    
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL);
        ok               = ok && (rec->alloc_trace_n > 0);
        // must find each one; a broken hash would miss some).
        for (u32 i = 0; i < N; i++) {
            DebugRecord *rec = MapGetFirstPtr(&dbg.live, ps[i]);
            ok               = ok && (rec != NULL);
            ok               = ok && (rec->requested_size == (size)(8 + (i & 31)));
        // captured frame count; reach in to require >= 2 frames so "#1" must
        // appear in a faithful render.
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL) && (rec->alloc_trace_n >= 2);
    
        // intentional bypass: snapshot the live record's frame count.
        DebugRecord *rec = MapGetFirstPtr(&dbg.live, p);
        ok               = ok && (rec != NULL) && (rec->alloc_trace_n >= 1);
        u32 n            = ok ? rec->alloc_trace_n : 0;
Last updated on