VirtualBox

Ignore:
Timestamp:
Jun 20, 2009 9:43:01 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48855
Message:

iprt: RTDbgMod coding in progress.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp

    r20360 r20739  
    99#include <iprt/mem.h>
    1010#include <iprt/string.h>
     11#include <iprt/strcache.h>
    1112#include "internal/dbgmod.h"
    1213
     
    2425    /** The name space core. */
    2526    RTSTRSPACECORE              NameCore;
    26     /** The name. */
    27     char                       *pszName;
    2827    /** The segent offset. */
    2928    RTUINTPTR                   off;
     
    5756    RTSTRSPACE                  Names;
    5857    /** The address space tree. */
    59     AVLRUINTPTRTREE             AddrTree;
     58    AVLRUINTPTRTREE             Addresses;
    6059    /** Segment table. */
    6160    PRTDBGMODCONTAINERSEGMENT   paSegs;
     
    7170
    7271/** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
    73 static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGLINE pLine)
    74 {
    75     return VINF_SUCCESS;
     72static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGLINE pLine)
     73{
     74    /** @todo Make it possible to add line numbers. */
     75    return VERR_DBG_NO_LINE_NUMBERS;
    7676}
    7777
    7878
    7979/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
    80 static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
     80static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
    8181{
    8282    return VINF_SUCCESS;
     
    9292
    9393/** @copydoc RTDBGMODVTDBG::pfnSymbolAdd */
    94 static DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, uint32_t iSeg, RTGCUINTPTR off, RTUINT cbSymbol)
    95 {
    96     return VINF_SUCCESS;
     94static DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, RTDBGSEGIDX iSeg, RTGCUINTPTR off, uint32_t cbSymbol)
     95{
     96    PRTDBGMODCONTAINER pThis = (PRTDBGMODCONTAINER)pMod->pvDbgPriv;
     97
     98    /*
     99     * Address validation. The other arguments have already been validated.
     100     */
     101    AssertMsgReturn(    (   iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
     102                         && iSeg <= RTDBGSEGIDX_SPECIAL_LAST)
     103                    ||  iSeg < pThis->cSegs,
     104                    ("iSeg=%x cSegs=%x\n", pThis->cSegs),
     105                    VERR_DBG_INVALID_SEGMENT_INDEX);
     106    AssertMsgReturn(    iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
     107                    ||  pThis->paSegs[iSeg].cb <= off + cbSymbol,
     108                    ("off=%RTptr cbSymbol=%RTptr cbSeg=%RTptr\n", off, cbSymbol, pThis->paSegs[iSeg].cb),
     109                    VERR_DBG_INVALID_SEGMENT_OFFSET);
     110
     111    /*
     112     * Create a new entry.
     113     */
     114    PRTDBGMODCONTAINERSYMBOL pSymbol = (PRTDBGMODCONTAINERSYMBOL)RTMemAllocZ(sizeof(*pSymbol));
     115    if (!pSymbol)
     116        return VERR_NO_MEMORY;
     117
     118#if 0 /* continue on the workstation */
     119    pSymbol->AddrCore.Key     = iSeg < RTDBGSEGIDX_SPECIAL_FIRST
     120                              ? pThis->paSegs->off + off
     121                              : off;
     122    pSymbol->AddrCore.KeyLast = pSymbol->AddrCore.Key + cbSymbol;
     123    pSymbol->off  = off;
     124    pSymbol->iSeg = iSeg;
     125    pSymbol->NameCore.pszString = RTStrCacheEnter(g_hDbgModStrCache, pszSymbol);
     126    if (pSymbol->NameCore.pszString)
     127    {
     128        if (RTStrSpaceInsert(&pThis->Names, &pSymbol->NameCore))
     129        {
     130            if (RTStrSpaceInsert(&pThis->Names, &pSymbol->NameCore))
     131            {
     132
     133            }
     134        }
     135    }
     136#endif
     137int rc = VERR_NOT_IMPLEMENTED;
     138
     139    return rc;
    97140}
    98141
     
    102145{
    103146    PRTDBGMODCONTAINERSYMBOL pSym = RT_FROM_MEMBER(pNode, RTDBGMODCONTAINERSYMBOL, AddrCore);
    104     RTStrFree(pSym->pszName);
     147    RTStrCacheRelease(g_hDbgModStrCache, pSym->NameCore.pszString);
    105148    RTMemFree(pSym);
    106149    return 0;
     
    116159     * Destroy the symbols and instance data.
    117160     */
    118     RTAvlrUIntPtrDestroy(&pThis->AddrTree, rtDbgModContainer_DestroyTreeNode, NULL);
     161    RTAvlrUIntPtrDestroy(&pThis->Addresses, rtDbgModContainer_DestroyTreeNode, NULL);
    119162    pThis->Names = NULL;
    120163    RTMemFree(pThis->paSegs);
     
    165208
    166209    pThis->Names = NULL;
    167     pThis->AddrTree = NULL;
     210    pThis->Addresses = NULL;
    168211    pThis->paSegs = NULL;
    169212    pThis->cSegs = 0;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette