Skip to content

PdbFunction

Description

One public function name + range from the PDB.

Fields

Name Description
rva Image-relative virtual address of the function start (= file-relative VA in PE / runtime_addr - ImageBase).
size Best-effort byte size. PDB S_PUB32 records don’t carry a size directly; we infer it as next_rva - this_rva after sorting, so the last function’s size is 0.
name Function name string. Borrowed from the PDB’s name pool; valid until PdbFileDeinit.

Usage example (Cross-references)

Usage examples (Cross-references)
        ok = pdb.functions.length == 1;
        if (ok) {
            const PdbFunction *f = &pdb.functions.data[0];
            ok                   = ok && f->rva == 0x1100 && f->name && ZstrCompare(f->name, "my_function") == 0;
        }
        // Direct lookup by RVA.
        if (ok) {
            const PdbFunction *f = PdbFileResolveRva(&pdb, 0x1100);
            ok                   = f && ZstrCompare(f->name, "my_function") == 0;
        }
        u32 rva = (u32)rva64;
    
        const PdbFunction *f = PdbFileResolveRva(&entry->pdb, rva);
        if (!f)
            return false;
        // names stay alive for the lifetime of the PdbFile.
        for (size i = 0; i < pending.length; ++i) {
            PdbFunction f = {
                .rva  = pending.data[i].rva,
                .size = 0,
    }
    
    const PdbFunction *PdbFileResolveRva(const PdbFile *self, u32 rva) {
        if (!self || self->functions.length == 0)
            return NULL;
        if (lo == 0)
            return NULL;
        const PdbFunction *f = &self->functions.data[lo - 1];
        // size == 0 means "until next entry"; we already accept that case.
        if (f->size > 0 && rva >= f->rva + f->size)
        u32         size;
        const char *name;
    } PdbFunction;
    
    typedef Vec(PdbFunction) PdbFunctions;
    } PdbFunction;
    
    typedef Vec(PdbFunction) PdbFunctions;
    
    ///
    /// FAILURE : Returns NULL.
    ///
    const PdbFunction *PdbFileResolveRva(const PdbFile *self, u32 rva);
    
    #endif // MISRA_PARSERS_PDB_H
Last updated on