VirtualBox

Ignore:
Timestamp:
Jun 7, 2009 1:22:52 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
48279
Message:

iprt: some more dbgmod bits.

Location:
trunk/src/VBox/Runtime/common/dbg
Files:
2 edited

Legend:

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

    r20355 r20356  
    172172        if (pDbgMod->pszName)
    173173        {
    174             pDbgMod->pDbgVt = &g_rtDbgModVtDbgContainer;
    175             rc = pDbgMod->pDbgVt->pfnTryOpen(pDbgMod);
     174            rc = rtDbgModContainerCreate(pDbgMod, cb);
    176175            if (RT_SUCCESS(rc))
    177176            {
     
    210209     */
    211210    RTCritSectEnter(&pDbgMod->CritSect); /* paranoia  */
     211
    212212    if (pDbgMod->pDbgVt)
     213    {
    213214        pDbgMod->pDbgVt->pfnClose(pDbgMod);
     215        pDbgMod->pDbgVt = NULL;
     216        pDbgMod->pvDbgPriv = NULL;
     217    }
     218
    214219    if (pDbgMod->pImgVt)
     220    {
    215221        pDbgMod->pImgVt->pfnClose(pDbgMod);
     222        pDbgMod->pImgVt = NULL;
     223        pDbgMod->pvImgPriv = NULL;
     224    }
    216225
    217226    /*
  • trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp

    r20355 r20356  
    77#include <iprt/avl.h>
    88#include <iprt/err.h>
     9#include <iprt/mem.h>
    910#include <iprt/string.h>
    1011#include "internal/dbgmod.h"
    1112
    1213
     14/*******************************************************************************
     15*   Structures and Typedefs                                                    *
     16*******************************************************************************/
     17/**
     18 * Symbol entry.
     19 */
     20typedef struct RTDBGMODCONTAINERSYMBOL
     21{
     22    /** The address core. */
     23    AVLRUINTPTRNODECORE         AddrCore;
     24    /** The name space core. */
     25    RTSTRSPACECORE              NameCore;
     26    /** The name. */
     27    char                       *pszName;
     28    /** The segent offset. */
     29    RTUINTPTR                   off;
     30    /** The segment index. */
     31    RTDBGSEGIDX                 iSeg;
     32} RTDBGMODCONTAINERSYMBOL;
     33/** Pointer to a symbol entry in the debug info container. */
     34typedef RTDBGMODCONTAINERSYMBOL *PRTDBGMODCONTAINERSYMBOL;
    1335
    14 /** @copydoc RTDBGMODVTDBG::pfnTryOpen */
    15 static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod)
     36/**
     37 * Segment entry.
     38 */
     39typedef struct RTDBGMODCONTAINERSEGMENT
     40{
     41    /** The segment offset. */
     42    RTUINTPTR                   off;
     43    /** The segment size. */
     44    RTUINTPTR                   cb;
     45    /** The segment name. */
     46    const char                 *pszName;
     47} RTDBGMODCONTAINERSEGMENT;
     48/** Pointer to a segment entry in the debug info container. */
     49typedef RTDBGMODCONTAINERSEGMENT *PRTDBGMODCONTAINERSEGMENT;
     50
     51/**
     52 * Instance data.
     53 */
     54typedef struct RTDBGMODCONTAINER
     55{
     56    /** The name space. */
     57    RTSTRSPACE                  Names;
     58    /** The address space tree. */
     59    AVLRUINTPTRTREE             AddrTree;
     60    /** Segment table. */
     61    PRTDBGMODCONTAINERSEGMENT   paSegs;
     62    /** The number of segments in the segment table. */
     63    RTDBGSEGIDX                 cSegs;
     64    /** The image size. 0 means unlimited. */
     65    RTUINTPTR                   cb;
     66} RTDBGMODCONTAINER;
     67/** Pointer to instance data for the debug info container. */
     68typedef RTDBGMODCONTAINER *PRTDBGMODCONTAINER;
     69
     70
     71
     72/** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
     73static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGLINE pLine)
    1674{
    1775    return VINF_SUCCESS;
     
    1977
    2078
    21 /** @copydoc RTDBGMODVTDBG::pfnClose */
    22 static DECLCALLBACK(int) rtDbgModContainer_Close(PRTDBGMODINT pMod)
     79/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
     80static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
     81{
     82    return VINF_SUCCESS;
     83}
     84
     85
     86/** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
     87static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
    2388{
    2489    return VINF_SUCCESS;
     
    3398
    3499
    35 /** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
    36 static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, PRTDBGSYMBOL pSymbol)
     100/** Destroy a symbol node. */
     101static DECLCALLBACK(int)  rtDbgModContainer_DestroyTreeNode(PAVLRUINTPTRNODECORE pNode, void *pvUser)
    37102{
     103    PRTDBGMODCONTAINERSYMBOL pSym = RT_FROM_MEMBER(pNode, RTDBGMODCONTAINERSYMBOL, AddrCore);
     104    RTStrFree(pSym->pszName);
     105    RTMemFree(pSym);
     106    return 0;
     107}
     108
     109
     110/** @copydoc RTDBGMODVTDBG::pfnClose */
     111static DECLCALLBACK(int) rtDbgModContainer_Close(PRTDBGMODINT pMod)
     112{
     113    PRTDBGMODCONTAINER pThis = (PRTDBGMODCONTAINER)pMod->pvDbgPriv;
     114
     115    /*
     116     * Destroy the symbols and instance data.
     117     */
     118    RTAvlrUIntPtrDestroy(&pThis->AddrTree, rtDbgModContainer_DestroyTreeNode, NULL);
     119    pThis->Names = NULL;
     120    RTMemFree(pThis->paSegs);
     121    pThis->paSegs = NULL;
     122    RTMemFree(pThis);
     123
    38124    return VINF_SUCCESS;
    39125}
    40126
    41127
    42 /** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
    43 static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGSYMBOL pSymbol)
     128/** @copydoc RTDBGMODVTDBG::pfnTryOpen */
     129static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod)
    44130{
    45     return VINF_SUCCESS;
     131    return VERR_INTERNAL_ERROR_5;
    46132}
    47133
    48134
    49 /** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
    50 static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, uint32_t iSeg, RTGCUINTPTR off, PRTGCINTPTR poffDisp, PRTDBGLINE pLine)
    51 {
    52     return VINF_SUCCESS;
    53 }
    54 
    55135
    56136/** Virtual function table for the debug info container. */
    57 RTDBGMODVTDBG const g_rtDbgModVtDbgContainer =
     137static RTDBGMODVTDBG const g_rtDbgModVtDbgContainer =
    58138{
    59139    /*.u32Magic = */            RTDBGMODVTDBG_MAGIC,
    60140    /*.fSupports = */           0, ///@todo iprt/types.h isn't up to date...
    61     /*.pszName = */             "CONTAINER",
     141    /*.pszName = */             "container",
    62142    /*.pfnTryOpen = */          rtDbgModContainer_TryOpen,
    63143    /*.pfnClose = */            rtDbgModContainer_Close,
     
    69149};
    70150
     151
     152
     153/**
     154 * Creates a
     155 *
     156 * @returns IPRT status code.
     157 * @param   pMod        The module instance.
     158 * @param   cb          The module size.
     159 */
     160int rtDbgModContainerCreate(PRTDBGMODINT pMod, RTUINTPTR cb)
     161{
     162    PRTDBGMODCONTAINER pThis = (PRTDBGMODCONTAINER)RTMemAlloc(sizeof(*pThis));
     163    if (!pThis)
     164        return VERR_NO_MEMORY;
     165
     166    pThis->Names = NULL;
     167    pThis->AddrTree = NULL;
     168    pThis->paSegs = NULL;
     169    pThis->cSegs = 0;
     170    pThis->cb = cb;
     171
     172    pMod->pDbgVt = &g_rtDbgModVtDbgContainer;
     173    pMod->pvDbgPriv = pThis;
     174    return VINF_SUCCESS;
     175}
     176
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