dbgmodcontainer.cpp revision 7af218a7441de38fc9e814919db04bae3e917664
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/*******************************************************************************
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync* Header Files *
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync*******************************************************************************/
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/*******************************************************************************
de6e321f351aa489a6a62bed474390a0056e8093vboxsync* Structures and Typedefs *
de6e321f351aa489a6a62bed474390a0056e8093vboxsync*******************************************************************************/
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * Symbol entry.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The address core. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The name space core. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The segent offset. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The segment index. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** Pointer to a symbol entry in the debug info container. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsynctypedef RTDBGMODCONTAINERSYMBOL *PRTDBGMODCONTAINERSYMBOL;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * Segment entry.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The segment offset. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The segment size. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The segment name. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync const char *pszName;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** Pointer to a segment entry in the debug info container. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsynctypedef RTDBGMODCONTAINERSEGMENT *PRTDBGMODCONTAINERSEGMENT;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * Instance data.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The name space. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The address space tree. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** Segment table. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The number of segments in the segment table. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync /** The image size. 0 means unlimited. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** Pointer to instance data for the debug info container. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
7af218a7441de38fc9e814919db04bae3e917664vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGLINE pLine)
7af218a7441de38fc9e814919db04bae3e917664vboxsync /** @todo Make it possible to add line numbers. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
7af218a7441de38fc9e814919db04bae3e917664vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** @copydoc RTDBGMODVTDBG::pfnSymbolAdd */
7af218a7441de38fc9e814919db04bae3e917664vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTGCUINTPTR off, uint32_t cbSymbol)
7af218a7441de38fc9e814919db04bae3e917664vboxsync PRTDBGMODCONTAINER pThis = (PRTDBGMODCONTAINER)pMod->pvDbgPriv;
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Address validation. The other arguments have already been validated.
7af218a7441de38fc9e814919db04bae3e917664vboxsync AssertMsgReturn( ( iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
7af218a7441de38fc9e814919db04bae3e917664vboxsync ("off=%RTptr cbSymbol=%RTptr cbSeg=%RTptr\n", off, cbSymbol, pThis->paSegs[iSeg].cb),
7af218a7441de38fc9e814919db04bae3e917664vboxsync * Create a new entry.
7af218a7441de38fc9e814919db04bae3e917664vboxsync PRTDBGMODCONTAINERSYMBOL pSymbol = (PRTDBGMODCONTAINERSYMBOL)RTMemAllocZ(sizeof(*pSymbol));
7af218a7441de38fc9e814919db04bae3e917664vboxsync#if 0 /* continue on the workstation */
7af218a7441de38fc9e814919db04bae3e917664vboxsync pSymbol->AddrCore.Key = iSeg < RTDBGSEGIDX_SPECIAL_FIRST
7af218a7441de38fc9e814919db04bae3e917664vboxsync pSymbol->AddrCore.KeyLast = pSymbol->AddrCore.Key + cbSymbol;
7af218a7441de38fc9e814919db04bae3e917664vboxsync pSymbol->NameCore.pszString = RTStrCacheEnter(g_hDbgModStrCache, pszSymbol);
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (RTStrSpaceInsert(&pThis->Names, &pSymbol->NameCore))
7af218a7441de38fc9e814919db04bae3e917664vboxsync if (RTStrSpaceInsert(&pThis->Names, &pSymbol->NameCore))
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** Destroy a symbol node. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_DestroyTreeNode(PAVLRUINTPTRNODECORE pNode, void *pvUser)
de6e321f351aa489a6a62bed474390a0056e8093vboxsync PRTDBGMODCONTAINERSYMBOL pSym = RT_FROM_MEMBER(pNode, RTDBGMODCONTAINERSYMBOL, AddrCore);
7af218a7441de38fc9e814919db04bae3e917664vboxsync RTStrCacheRelease(g_hDbgModStrCache, pSym->NameCore.pszString);
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** @copydoc RTDBGMODVTDBG::pfnClose */
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_Close(PRTDBGMODINT pMod)
de6e321f351aa489a6a62bed474390a0056e8093vboxsync PRTDBGMODCONTAINER pThis = (PRTDBGMODCONTAINER)pMod->pvDbgPriv;
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * Destroy the symbols and instance data.
7af218a7441de38fc9e814919db04bae3e917664vboxsync RTAvlrUIntPtrDestroy(&pThis->Addresses, rtDbgModContainer_DestroyTreeNode, NULL);
de6e321f351aa489a6a62bed474390a0056e8093vboxsync/** @copydoc RTDBGMODVTDBG::pfnTryOpen */
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncstatic DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod)
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync/** Virtual function table for the debug info container. */
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncstatic RTDBGMODVTDBG const g_rtDbgModVtDbgContainer =
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*.fSupports = */ 0, ///@todo iprt/types.h isn't up to date...
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*.pfnSymbolByName = */ rtDbgModContainer_SymbolByName,
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*.pfnSymbolByAddr = */ rtDbgModContainer_SymbolByAddr,
172ae196da38208e5f1e3485715a89f2d53c6880vboxsync /*.pfnLineByAddr = */ rtDbgModContainer_LineByAddr,
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Creates a generic debug info container and associates it with the module.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * @returns IPRT status code.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * @param pMod The module instance.
de6e321f351aa489a6a62bed474390a0056e8093vboxsync * @param cb The module size.
de6e321f351aa489a6a62bed474390a0056e8093vboxsyncint rtDbgModContainerCreate(PRTDBGMODINT pMod, RTUINTPTR cb)