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

static int kdbgModuleOpenWorker ( PPKDBGMOD  ppDbgMod,
PKRDR  pRdr,
KBOOL  fCloseRdr,
KFOFF  off,
KFOFF  cb,
struct KLDRMOD pLdrMod 
) [static]

Worker for the kDbgModuleOpen* APIs.

This will make sure the reader is buffered. I will also take care of closing the reader opened by kDbgModuleOpen on failure.

Returns:
0 on success. An appropriate kErrors status code on failure.
Parameters:
ppDbgMod Where to store the new debug module reader instance.
pRdr The file provider.
fCloseRdr Whether pRdr should be close or not. This applies both to the failure path and to the success path, where it'll be close when the module is closed by kDbgModuleClose().
off The offset into the file where the debug info is supposed to be found. This is 0 if the entire file is the subject.
cb The size of the debug info part of the file. This is KFOFF_MAX if the entire file is the subject.
pLdrMod An optional kLdrMod association.

Definition at line 178 of file kDbgModule.cpp.

References K_ELEMENTS, KDBG_ERR_UNKOWN_FORMAT, KSIZE, NULL, KDBGMODOPS::pfnOpen, and KDBGMODOPS::pNext.

{
    /*
     * If the reader isn't buffered create a buffered wrapper for it.
     */
    int rc;
    PKRDR pRdrWrapped = NULL;
    if (!kRdrBufIsBuffered(pRdr))
    {
        rc = kRdrBufWrap(&pRdrWrapped, pRdr, fCloseRdr);
        if (rc)
        {
            if (fCloseRdr)
                kRdrClose(pRdr);
            return rc;
        }
        pRdr = pRdrWrapped;
    }

    /*
     * Walk the built-in table and the list of registered readers
     * and let each of them have a go at the file. Stop and return
     * on the first one returning successfully.
     */
    rc = KDBG_ERR_UNKOWN_FORMAT;
    for (KSIZE i = 0; i < K_ELEMENTS(g_aBuiltIns); i++)
        if (g_aBuiltIns[i]->pfnOpen)
        {
            int rc2 = g_aBuiltIns[i]->pfnOpen(ppDbgMod, pRdr, fCloseRdr, off, cb, pLdrMod);
            if (!rc2)
                return 0;
            if (rc2 != KDBG_ERR_UNKOWN_FORMAT && rc == KDBG_ERR_UNKOWN_FORMAT)
                rc = rc2;
        }

    for (PKDBGMODOPS pCur = g_pHead; pCur; pCur = pCur->pNext)
        if (pCur->pfnOpen)
        {
            int rc2 = pCur->pfnOpen(ppDbgMod, pRdr, fCloseRdr, off, cb, pLdrMod);
            if (!rc2)
                return 0;
            if (rc2 != KDBG_ERR_UNKOWN_FORMAT && rc == KDBG_ERR_UNKOWN_FORMAT)
                rc = rc2;
        }

    if (pRdrWrapped)
        kRdrClose(pRdrWrapped);
    else if (fCloseRdr)
        kRdrClose(pRdr);
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index