dbgmoddeferred.cpp revision d90eec53c9dcaa0f3d1054e8734ed46875b9093a
/* $Id$ */
/** @file
* IPRT - Debug Module Deferred Loading Stub.
*/
/*
* Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
/**
* Releases the instance data.
*
* @param pThis The instance data.
*/
{
if (!cRefs)
{
}
}
/**
*
* @returns VINF_SUCCESS or VERR_DBG_DEFERRED_LOAD_FAILED.
* @param pMod The generic module instance data.
* @param fForcedRetry Whether it's a forced retry by one of the
* pfnTryOpen methods.
*/
{
int rc;
{
/* Reset the method tables and private data pointes so the deferred loading
procedure can figure out what to do and won't get confused. */
if (fDbgVt)
{
}
if (fImgVt)
{
}
/* Do the deferred loading. */
if (RT_SUCCESS(rc))
{
pMod->fDeferredFailed = false;
}
else
{
/* Failed, bail out and restore the deferred setup. */
pMod->fDeferredFailed = true;
if (fDbgVt)
{
}
if (fImgVt)
{
}
}
}
else
return rc;
}
/*
*
* D e b u g I n f o M e t h o d s
* D e b u g I n f o M e t h o d s
* D e b u g I n f o M e t h o d s
*
*/
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByAddr} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineByOrdinal} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_LineByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineCount} */
{
if (RT_SUCCESS(rc))
return 0;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnLineAdd} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_LineAdd(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
{
if (RT_SUCCESS(rc))
return rc;
}
/**
* Fill in symbol info for the fake start symbol.
*
* @returns VINF_SUCCESS
* @param pThis The deferred load data.
* @param pSymInfo The output structure.
*/
{
return VINF_SUCCESS;
}
/**
* Fill in symbol info for the fake last symbol.
*
* @returns VINF_SUCCESS
* @param pThis The deferred load data.
* @param pSymInfo The output structure.
*/
{
return VINF_SUCCESS;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByAddr} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
{
if (RT_SUCCESS(rc))
else
{
if (off == 0)
else
if (poffDisp)
}
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByName} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
{
if (RT_SUCCESS(rc))
else
{
else
}
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolByOrdinal} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
{
if (RT_SUCCESS(rc))
else
{
if (iOrdinal == 0)
else if (iOrdinal == 1)
else
}
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolCount} */
{
if (RT_SUCCESS(rc))
return 2;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSymbolAdd} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentByIndex} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
{
if (RT_SUCCESS(rc))
else if (iSeg == 0)
{
}
else
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentCount} */
{
if (RT_SUCCESS(rc))
return 1;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnSegmentAdd} */
static DECLCALLBACK(int) rtDbgModDeferredDbg_SegmentAdd(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName,
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnImageSize} */
{
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnRvaToSegOff} */
static DECLCALLBACK(RTDBGSEGIDX) rtDbgModDeferredDbg_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
{
if (RT_SUCCESS(rc))
return 0;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnClose} */
{
return VINF_SUCCESS;
}
/** @interface_method_impl{RTDBGMODVTDBG,pfnTryOpen} */
{
}
/** Virtual function table for the deferred debug info reader. */
{
/*.u32Magic = */ RTDBGMODVTDBG_MAGIC,
/*.fSupports = */ RT_DBGTYPE_MAP,
/*.pszName = */ "deferred",
/*.pfnTryOpen = */ rtDbgModDeferredDbg_TryOpen,
/*.pfnClose = */ rtDbgModDeferredDbg_Close,
/*.pfnRvaToSegOff = */ rtDbgModDeferredDbg_RvaToSegOff,
/*.pfnImageSize = */ rtDbgModDeferredDbg_ImageSize,
/*.pfnSegmentAdd = */ rtDbgModDeferredDbg_SegmentAdd,
/*.pfnSegmentCount = */ rtDbgModDeferredDbg_SegmentCount,
/*.pfnSegmentByIndex = */ rtDbgModDeferredDbg_SegmentByIndex,
/*.pfnSymbolAdd = */ rtDbgModDeferredDbg_SymbolAdd,
/*.pfnSymbolCount = */ rtDbgModDeferredDbg_SymbolCount,
/*.pfnSymbolByOrdinal = */ rtDbgModDeferredDbg_SymbolByOrdinal,
/*.pfnSymbolByName = */ rtDbgModDeferredDbg_SymbolByName,
/*.pfnSymbolByAddr = */ rtDbgModDeferredDbg_SymbolByAddr,
/*.pfnLineAdd = */ rtDbgModDeferredDbg_LineAdd,
/*.pfnLineCount = */ rtDbgModDeferredDbg_LineCount,
/*.pfnLineByOrdinal = */ rtDbgModDeferredDbg_LineByOrdinal,
/*.pfnLineByAddr = */ rtDbgModDeferredDbg_LineByAddr,
/*.u32EndMagic = */ RTDBGMODVTDBG_MAGIC
};
/*
*
* I m a g e M e t h o d s
* I m a g e M e t h o d s
* I m a g e M e t h o d s
*
*/
/** @interface_method_impl{RTDBGMODVTIMG,pfnUnmapPart} */
static DECLCALLBACK(int) rtDbgModDeferredImg_UnmapPart(PRTDBGMODINT pMod, size_t cb, void const **ppvMap)
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnMapPart} */
static DECLCALLBACK(int) rtDbgModDeferredImg_MapPart(PRTDBGMODINT pMod, RTFOFF off, size_t cb, void const **ppvMap)
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnImageSize} */
{
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnLinkAddressToSegOffset} */
static DECLCALLBACK(int) rtDbgModDeferredImg_LinkAddressToSegOffset(PRTDBGMODINT pMod, RTLDRADDR LinkAddress,
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnEnumSegments} */
static DECLCALLBACK(int) rtDbgModDeferredImg_EnumSegments(PRTDBGMODINT pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser)
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnEnumDbgInfo} */
static DECLCALLBACK(int) rtDbgModDeferredImg_EnumDbgInfo(PRTDBGMODINT pMod, PFNRTLDRENUMDBG pfnCallback, void *pvUser)
{
if (RT_SUCCESS(rc))
return rc;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnClose} */
{
return VINF_SUCCESS;
}
/** @interface_method_impl{RTDBGMODVTIMG,pfnTryOpen} */
{
}
/** Virtual function table for the RTLdr based image reader. */
{
/*.u32Magic = */ RTDBGMODVTIMG_MAGIC,
/*.fReserved = */ 0,
/*.pszName = */ "deferred",
/*.pfnTryOpen = */ rtDbgModDeferredImg_TryOpen,
/*.pfnClose = */ rtDbgModDeferredImg_Close,
/*.pfnEnumDbgInfo = */ rtDbgModDeferredImg_EnumDbgInfo,
/*.pfnEnumSegments = */ rtDbgModDeferredImg_EnumSegments,
/*.pfnGetLoadedSize = */ rtDbgModDeferredImg_ImageSize,
/*.pfnLinkAddressToSegOffset = */ rtDbgModDeferredImg_LinkAddressToSegOffset,
/*.pfnMapPart = */ rtDbgModDeferredImg_MapPart,
/*.pfnUnmapPart = */ rtDbgModDeferredImg_UnmapPart,
/*.u32EndMagic = */ RTDBGMODVTIMG_MAGIC
};
/**
* Creates a deferred loading stub for both image and debug info.
*
* @returns IPRT status code.
* @param pDbgMod The debug module.
* @param pfnDeferred The callback that will try load the image and
* debug info.
* @param cbImage The size of the image.
* @param hDbgCfg The debug config handle. Can be NIL. A
* reference will be retained.
* @param ppDeferred Where to return the instance data. Can be NULL.
*/
DECLHIDDEN(int) rtDbgModDeferredCreate(PRTDBGMODINT pDbgMod, PFNRTDBGMODDEFERRED pfnDeferred, RTUINTPTR cbImage,
{
if (!pDeferred)
return VERR_NO_MEMORY;
if (hDbgCfg != NIL_RTDBGCFG)
{
}
pDbgMod->fDeferredFailed = false;
if (ppDeferred)
*ppDeferred = pDeferred;
return VINF_SUCCESS;
}