dbgmodcontainer.cpp revision ca3da10d05961c339b5180fbd40a54587d6bad35
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/strcache.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Symbol entry.
*/
typedef struct RTDBGMODCONTAINERSYMBOL
{
/** The address core. */
/** The name space core. */
/** The segment index. */
/** The symbol flags. */
/** The symbol size.
* This may be zero while the range in AddrCore indicates 0. */
/** Pointer to a symbol entry in the debug info container. */
/** Pointer to a const symbol entry in the debug info container. */
typedef RTDBGMODCONTAINERSYMBOL const *PCRTDBGMODCONTAINERSYMBOL;
/**
* Line number entry.
*/
typedef struct RTDBGMODCONTAINERLINE
{
/** The address core.
* The Key is the address of the line number. */
/** Pointer to the file name (in string cache). */
const char *pszFile;
/** The line number. */
/** Pointer to a line number entry. */
typedef RTDBGMODCONTAINERLINE *PRTDBGMODCONTAINERLINE;
/** Pointer to const a line number entry. */
typedef RTDBGMODCONTAINERLINE const *PCRTDBGMODCONTAINERLINE;
/**
* Segment entry.
*/
typedef struct RTDBGMODCONTAINERSEGMENT
{
/** The symbol address space tree. */
/** The line number address space tree. */
/** The segment offset. */
/** The segment size. */
/** The segment name. */
const char *pszName;
/** Pointer to a segment entry in the debug info container. */
/** Pointer to a const segment entry in the debug info container. */
typedef RTDBGMODCONTAINERSEGMENT const *PCRTDBGMODCONTAINERSEGMENT;
/**
* Instance data.
*/
typedef struct RTDBGMODCONTAINER
{
/** The name space. */
/** Tree containing any absolute addresses. */
/** Segment table. */
/** The number of segments in the segment table. */
/** The image size. 0 means unlimited. */
/** Pointer to instance data for the debug info container. */
typedef RTDBGMODCONTAINER *PRTDBGMODCONTAINER;
/**
* Fills in a RTDBGSYMBOL structure.
*
* @returns VINF_SUCCESS.
* @param pMySym Our internal symbol representation.
* @param pExtSym The external symbol representation.
*/
DECLINLINE(int) rtDbgModContainerReturnSymbol(PCRTDBGMODCONTAINERSYMBOL pMySym, PRTDBGSYMBOL pExtSym)
{
return VINF_SUCCESS;
}
/** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
{
/*
* Validate the input address.
*/
/*
* Lookup the nearest line number with an address less or equal to the specified address.
*/
PAVLUINTPTRNODECORE pAvlCore = RTAvlUIntPtrGetBestFit(&pThis->paSegs[iSeg].LineAddrTree, off, false /*fAbove*/);
if (!pAvlCore)
return VERR_SYMBOL_NOT_FOUND;
if (poffDisp)
return VINF_SUCCESS;
}
/** @copydoc RTDBGMODVTDBG::pfnLineAdd */
static DECLCALLBACK(int) rtDbgModContainer_LineAdd(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
{
/*
* Validate the input address.
*/
AssertMsgReturn(pThis->paSegs[iSeg].cb < off, ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
/*
* Create a new entry.
*/
if (!pLine)
return VERR_NO_MEMORY;
int rc;
{
return VINF_SUCCESS;
/* bail out */
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
{
/*
* Validate the input address.
*/
/*
* Lookup the nearest symbol with an address less or equal to the specified address.
*/
? &pThis->AbsAddrTree
off,
false /*fAbove*/);
if (!pAvlCore)
return VERR_SYMBOL_NOT_FOUND;
PCRTDBGMODCONTAINERSYMBOL pMySym = RT_FROM_MEMBER(pAvlCore, RTDBGMODCONTAINERSYMBOL const, AddrCore);
if (poffDisp)
}
/** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
{
/*
* Look it up in the name space.
*/
if (!pStrCore)
return VERR_SYMBOL_NOT_FOUND;
PCRTDBGMODCONTAINERSYMBOL pMySym = RT_FROM_MEMBER(pStrCore, RTDBGMODCONTAINERSYMBOL const, NameCore);
}
/** @copydoc RTDBGMODVTDBG::pfnSymbolAdd */
static DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
{
/*
* Address validation. The other arguments have already been validated.
*/
/*
* Create a new entry.
*/
if (!pSymbol)
return VERR_NO_MEMORY;
int rc;
{
{
? &pThis->AbsAddrTree
return VINF_SUCCESS;
/* bail out */
}
else
}
else
rc = VERR_NO_MEMORY;
return rc;
}
/** @copydoc RTDBGMODVTDBG::pfnRvaToSegOff */
static DECLCALLBACK(RTDBGSEGIDX) rtDbgModContainer_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
{
if (cSegs <= 7)
{
/*
* Linear search.
*/
{
{
if (poffSeg)
return iSeg;
}
}
}
else
{
/*
* Binary search.
*/
for (;;)
{
{
if (poffSeg)
return iSeg;
}
/* advance */
{
/* between iFirst and iSeg. */
break;
}
else
{
/* between iSeg and iLast. */
break;
}
}
}
/* Invalid. */
return NIL_RTDBGSEGIDX;
}
/** Destroy a symbol node. */
static DECLCALLBACK(int) rtDbgModContainer_DestroyTreeNode(PAVLRUINTPTRNODECORE pNode, void *pvUser)
{
return 0;
}
/** @copydoc RTDBGMODVTDBG::pfnClose */
{
/*
* Destroy the symbols and instance data.
*/
{
}
return VINF_SUCCESS;
}
/** @copydoc RTDBGMODVTDBG::pfnTryOpen */
{
return VERR_INTERNAL_ERROR_5;
}
/** Virtual function table for the debug info container. */
static RTDBGMODVTDBG const g_rtDbgModVtDbgContainer =
{
/*.u32Magic = */ RTDBGMODVTDBG_MAGIC,
/*.pszName = */ "container",
/*.pfnTryOpen = */ rtDbgModContainer_TryOpen,
/*.pfnClose = */ rtDbgModContainer_Close,
/*.pfnRvaToSegOff = */ rtDbgModContainer_RvaToSegOff,
/*.pfnSymbolAdd = */ rtDbgModContainer_SymbolAdd,
/*.pfnSymbolByName = */ rtDbgModContainer_SymbolByName,
/*.pfnSymbolByAddr = */ rtDbgModContainer_SymbolByAddr,
/*.pfnLineAdd = */ rtDbgModContainer_LineAdd,
/*.pfnLineByAddr = */ rtDbgModContainer_LineByAddr,
/*.u32EndMagic = */ RTDBGMODVTDBG_MAGIC
};
/**
* Creates a generic debug info container and associates it with the module.
*
* @returns IPRT status code.
* @param pMod The module instance.
* @param cb The module size.
*/
{
if (!pThis)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
}