Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

static int KPRF_NAME() Dump ( KPRF_TYPE(PC, HDR)  pHdr,
FILE *  pOut 
) [static]

Dumps a file of a particular format.

Returns:
0 on success. (you might want to check the pOut state)

-1 on failure.

Parameters:
pHdr Pointer to the data set.
pOut The output file. This is opened for text writing.
pReader The reader object.

Definition at line 132 of file prfreader.cpp.h.

References KPRF_ALIGN, KPRF_OFF2PTR, KPRF_OFFSETOF, KPRF_TYPE, NULL, and KDBGSYMBOL::szName.

{
    /*
     * Any commandline?
     */
    if (pHdr->offCommandLine)
        fprintf(pOut,
                "Commandline: %s (%d  bytes)\n",
                (char *)KPRF_OFF2PTR(PC,MODSEG, pHdr->offCommandLine, pHdr), /* stupid, stupid, type hacking. */
                pHdr->cchCommandLine);

    /*
     * Dump the module segments.
     */
    fprintf(pOut,
            "Module Segments: off=0x%x 0x%x/0x%x (bytes)\n"
            "----------------\n",
            pHdr->offModSegs, pHdr->cbModSegs, pHdr->cbMaxModSegs);
    KU32 off = pHdr->offModSegs;
    while (off < pHdr->offModSegs + pHdr->cbModSegs)
    {
        KPRF_TYPE(PC,MODSEG) pCur = KPRF_OFF2PTR(PC,MODSEG, off, pHdr);
        KU32 cbCur = KPRF_OFFSETOF(MODSEG, szPath[pCur->cchPath + 1]);
        cbCur = KPRF_ALIGN(cbCur, KPRF_SIZEOF(UPTR));

        fprintf(pOut,
                "0x%04x: iSegment=0x%08x uBasePtr=%" KPRF_FMT_UPTR " szPath='%s' (%d bytes)\n",
                off, pCur->iSegment, pCur->uBasePtr, pCur->szPath, pCur->cchPath);

        /* next */
        off += cbCur;
    }
    fprintf(pOut, "\n");

    /*
     * Dump the functions.
     */
    fprintf(pOut,
            "Functions: off=0x%x 0x%x/0x%x\n"
            "----------\n",
            pHdr->offFunctions, pHdr->cFunctions, pHdr->cMaxFunctions);
    KPRF_TYPE(PC,FUNC) paFuncs = KPRF_OFF2PTR(PC,FUNC, pHdr->offFunctions, pHdr);
    for (KU32 i = 0; i < pHdr->cFunctions; i++)
    {
        KPRF_TYPE(PC,FUNC) pCur = &paFuncs[i];
        fprintf(pOut, "0x%04x: uEntryPtr=%" KPRF_FMT_UPTR " cOnStack=0x%" KPRF_FMT_X64 " cCalls=0x%" KPRF_FMT_X64 "\n"
                      "       OnStack={0x%" KPRF_FMT_X64 ", 0x%" KPRF_FMT_X64 ", 0x%" KPRF_FMT_X64 "}\n"
                      "  OnTopOfStack={0x%" KPRF_FMT_X64 ", 0x%" KPRF_FMT_X64 ", 0x%" KPRF_FMT_X64 "}\n",
                i, pCur->uEntryPtr, pCur->cOnStack, pCur->cCalls,
                pCur->OnStack.MinTicks, pCur->OnStack.MaxTicks,  pCur->OnStack.SumTicks,
                pCur->OnTopOfStack.MinTicks, pCur->OnTopOfStack.MaxTicks,  pCur->OnTopOfStack.SumTicks);
        if (pCur->offModSeg)
        {
            KPRF_TYPE(PC,MODSEG) pModSeg = KPRF_OFF2PTR(PC,MODSEG, pCur->offModSeg, pHdr);
            fprintf(pOut, "  offModSeg=0x%08x iSegment=0x%02x uBasePtr=%" KPRF_FMT_UPTR " szPath='%s' (%d bytes)\n",
                    pCur->offModSeg, pModSeg->iSegment, pModSeg->uBasePtr, pModSeg->szPath, pModSeg->cchPath);

#if 1
            PKDBGMOD pMod;
            int rc = kDbgModuleOpen(&pMod, pModSeg->szPath, NULL /* pLdrMod */);
            if (!rc)
            {
                KDBGSYMBOL Sym;
                rc = kDbgModuleQuerySymbol(pMod, pModSeg->iSegment, pCur->uEntryPtr - pModSeg->uBasePtr, &Sym);
                if (!rc)
                {
                    fprintf(pOut, "  %s\n", Sym.szName);
                }
                kDbgModuleClose(pMod);
            }
#endif

        }
    }
    fprintf(pOut, "\n");

    /*
     * Dump the threads.
     */
    fprintf(pOut,
            "Threads: off=0x%x 0x%x/0x%x (Stacks=0x%x/0x%x cMaxStackFrames=0x%x)\n"
            "--------\n",
            pHdr->offThreads, pHdr->cThreads, pHdr->cMaxThreads, pHdr->cStacks, pHdr->cMaxStacks, pHdr->cMaxStackFrames);
    KPRF_TYPE(PC,THREAD) paThreads = KPRF_OFF2PTR(PC,THREAD, pHdr->offThreads, pHdr);
    for (KU32 i = 0; i < pHdr->cThreads; i++)
    {
        KPRF_TYPE(PC,THREAD) pCur = &paThreads[i];
        fprintf(pOut,
                "0x%02x: ThreadId=0x%08" KPRF_FMT_X64 " enmState=%d szName='%s'\n"
                "  uStackBasePtr=%" KPRF_FMT_UPTR " cbMaxStack=%" KPRF_FMT_UPTR "\n"
                "  cCalls=0x%" KPRF_FMT_X64 " cOverflows=0x%" KPRF_FMT_X64 " cStackSwitchRejects=0x%" KPRF_FMT_X64 "\n"
                "  cUnwinds=0x%" KPRF_FMT_X64 " ProfiledTicks=0x%" KPRF_FMT_X64 " OverheadTicks=0x%" KPRF_FMT_X64 "\n",
                i, pCur->ThreadId, pCur->enmState, pCur->szName,
                pCur->uStackBasePtr, pCur->cbMaxStack,
                pCur->cCalls, pCur->cOverflows, pCur->cStackSwitchRejects,
                pCur->cUnwinds, pCur->ProfiledTicks, pCur->OverheadTicks);
    }

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index