Skip to content
PdbCacheDeinit

PdbCacheDeinit

Description

Tear down the cache, releasing every cached Pe and Pdb. Safe on a zeroed struct.

Success

Returns to the caller. self is zeroed.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
    // ---------------------------------------------------------------------------
    
    void PdbCacheDeinit(PdbCache *self) {
        if (!self)
            return;
    #    if FEATURE_PARSER_PDB
        if (pdb_cache_ok)
            PdbCacheDeinit(&pdb_cache);
    #    endif
    }
        ok            = ok && name && ZstrCompare(name, "winproc") == 0 && offset == 0x10;
    
        PdbCacheDeinit(&cache);
        DefaultAllocatorDeinit(&alloc);
        Zstr     name  = NULL;
        bool     ok    = !PdbCacheResolve(&cache, (Zstr)missing, 0, 0x1000, &name, NULL);
        PdbCacheDeinit(&cache);
        DefaultAllocatorDeinit(&alloc);
        return ok;
            ok              = PdbCacheResolve(&cache, pe_name, mbase, mbase + 0x1100, &name, &off);
            ok              = ok && name && ZstrCompare(name, "winproc") == 0 && off == 0;
            PdbCacheDeinit(&cache);
        }
            // PE opens, PDB lookup fails -> resolve returns false.
            ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
            PdbCacheDeinit(&cache);
            // Teardown returns every allocation (the failed-lookup candidate too).
            ok = ok && DebugAllocatorLiveCount(&alloc) == baseline;
            // PDB opens but GUID/age disagree -> resolve rejects it.
            ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
            PdbCacheDeinit(&cache);
            // The briefly-opened, then-rejected PDB must be freed.
            ok = ok && DebugAllocatorLiveCount(&alloc) == baseline;
            ok = ra && rb && rb2 && name2 && ZstrCompare(name2, "winproc") == 0 && after == mid;
    
            PdbCacheDeinit(&cache);
        }
            bool grew = r && DebugAllocatorLiveCount(&alloc) > baseline;
    
            PdbCacheDeinit(&cache);
            // Correct teardown releases every cached allocation.
            ok = grew && DebugAllocatorLiveCount(&alloc) == baseline;
            ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase, &name, &off);
            ok = ok && name && ZstrCompare(name, "winzero") == 0 && off == 0;
            PdbCacheDeinit(&cache);
        }
            ok              = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0xFFFFFFFFull, &name, &off);
            ok              = ok && name && ZstrCompare(name, "winmax") == 0 && off == 0;
            PdbCacheDeinit(&cache);
        }
                ok = !PdbCacheResolve(&cache, &mod, mbase, mbase - 1, &name, &off);
            }
            PdbCacheDeinit(&cache);
        }
            ok              = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0x1100, &name, &off);
            ok              = ok && name && ZstrCompare(name, "winproc") == 0 && off == 0;
            PdbCacheDeinit(&cache);
        }
            Zstr     name  = NULL;
            ok             = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
            PdbCacheDeinit(&cache);
            ok = ok && DebugAllocatorLiveCount(&alloc) == baseline;
        }
            bool      rb    = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &nb, &off);
            ok              = ra && rb && na && nb && ZstrCompare(na, "aproc") == 0 && ZstrCompare(nb, "bproc") == 0;
            PdbCacheDeinit(&cache);
        }
            bool grew = ra && rb && DebugAllocatorLiveCount(&alloc) > baseline;
    
            PdbCacheDeinit(&cache);
            // Freeing EVERY entry (not just the first) returns to baseline.
            ok = grew && DebugAllocatorLiveCount(&alloc) == baseline;
            AllocatorFree(&bp, probe);
    
        PdbCacheDeinit(&cache);
        BudgetAllocatorDeinit(&bp);
        return freed;
Last updated on