VirtualBox

Changeset 22108 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Aug 9, 2009 12:42:45 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50859
Message:

DBGC: plug-ins in the works.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/DBGFAddrSpace.cpp

    r21111 r22108  
    589589            psz++;
    590590
    591         /* Fine the end of this element. */
     591        /* Find the end of this element. */
    592592        const char *pszNext;
    593593        const char *pszEnd = strchr(psz, ';');
  • trunk/src/VBox/VMM/DBGFOS.cpp

    r19300 r22108  
    3030#include <VBox/vm.h>
    3131#include <VBox/err.h>
    32 
    3332#include <VBox/log.h>
     33
     34#include <iprt/assert.h>
    3435#include <iprt/thread.h>
    35 #include <iprt/assert.h>
    36 
     36#include <iprt/param.h>
     37
     38
     39/*******************************************************************************
     40*   Defined Constants And Macros                                               *
     41*******************************************************************************/
     42#define DBGF_OS_READ_LOCK(pVM)      do { } while (0)
     43#define DBGF_OS_READ_UNLOCK(pVM)    do { } while (0)
     44
     45#define DBGF_OS_WRITE_LOCK(pVM)     do { } while (0)
     46#define DBGF_OS_WRITE_UNLOCK(pVM)   do { } while (0)
     47
     48
     49/**
     50 * Internal cleanup routine called by DBGFR3Term().
     51 *
     52 * @param   pVM     Pointer to the shared VM structure.
     53 */
     54void dbgfR3OSTerm(PVM pVM)
     55{
     56    /*
     57     * Terminate the current one.
     58     */
     59    if (pVM->dbgf.s.pCurOS)
     60    {
     61        pVM->dbgf.s.pCurOS->pReg->pfnTerm(pVM, pVM->dbgf.s.pCurOS->abData);
     62        pVM->dbgf.s.pCurOS = NULL;
     63    }
     64
     65    /*
     66     * Destroy all the instances.
     67     */
     68    while (pVM->dbgf.s.pOSHead)
     69    {
     70        PDBGFOS pOS = pVM->dbgf.s.pOSHead;
     71        pVM->dbgf.s.pOSHead = pOS->pNext;
     72        if (pOS->pReg->pfnDestruct)
     73            pOS->pReg->pfnDestruct(pVM, pOS->abData);
     74        MMR3HeapFree(pOS);
     75    }
     76}
    3777
    3878
     
    4787{
    4888    /* more validations. */
     89    DBGF_OS_READ_LOCK(pVM);
    4990    PDBGFOS pOS;
    5091    for (pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext)
    5192        if (!strcmp(pOS->pReg->szName, pReg->szName))
    5293        {
     94            DBGF_OS_READ_UNLOCK(pVM);
    5395            Log(("dbgfR3OSRegister: %s -> VERR_ALREADY_LOADED\n", pReg->szName));
    5496            return VERR_ALREADY_LOADED;
     
    65107    if (RT_SUCCESS(rc))
    66108    {
     109        DBGF_OS_WRITE_LOCK(pVM);
    67110        pOS->pNext = pVM->dbgf.s.pOSHead;
    68111        pVM->dbgf.s.pOSHead = pOS;
     112        DBGF_OS_WRITE_UNLOCK(pVM);
    69113    }
    70114    else
     
    95139     * Validate intput.
    96140     */
     141    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     142
    97143    AssertPtrReturn(pReg, VERR_INVALID_POINTER);
    98144    AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC);
     
    115161     */
    116162    PVMREQ pReq;
    117     int rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSRegister, 2, pVM, pReg);
     163    int rc = VMR3ReqCallU(pVM->pUVM, 0, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSRegister, 2, pVM, pReg);
    118164    if (RT_SUCCESS(rc))
    119165        rc = pReq->iStatus;
     
    125171
    126172/**
    127  * Internal cleanup routine called by DBGFR3Term().
    128  *
     173 * EMT worker function for DBGFR3OSDeregister.
     174 *
     175 * @returns VBox status code.
    129176 * @param   pVM     Pointer to the shared VM structure.
    130  */
    131 void dbgfR3OSTerm(PVM pVM)
    132 {
    133     /*
    134      * Terminate the current one.
    135      */
    136     if (pVM->dbgf.s.pCurOS)
    137     {
    138         pVM->dbgf.s.pCurOS->pReg->pfnTerm(pVM, pVM->dbgf.s.pCurOS->abData);
    139         pVM->dbgf.s.pCurOS = NULL;
    140     }
    141 
    142     /*
    143      * Destroy all the instances.
    144      */
    145     while (pVM->dbgf.s.pOSHead)
    146     {
    147         PDBGFOS pOS = pVM->dbgf.s.pOSHead;
    148         pVM->dbgf.s.pOSHead = pOS->pNext;
    149         if (pOS->pReg->pfnDestruct)
    150             pOS->pReg->pfnDestruct(pVM, pOS->abData);
    151         MMR3HeapFree(pOS);
    152     }
     177 * @param   pReg    The registration structure.
     178 */
     179static DECLCALLBACK(int) dbgfR3OSDeregister(PVM pVM, PDBGFOSREG pReg)
     180{
     181    /*
     182     * Unlink it.
     183     */
     184    bool    fWasCurOS = false;
     185    PDBGFOS pOSPrev   = NULL;
     186    PDBGFOS pOS;
     187    DBGF_OS_WRITE_LOCK(pVM);
     188    for (pOS = pVM->dbgf.s.pOSHead; pOS; pOSPrev = pOS, pOS = pOS->pNext)
     189        if (pOS->pReg == pReg)
     190        {
     191            if (pOSPrev)
     192                pOSPrev->pNext = pOS->pNext;
     193            else
     194                pVM->dbgf.s.pOSHead = pOS->pNext;
     195            if (pVM->dbgf.s.pCurOS == pOS)
     196            {
     197                pVM->dbgf.s.pCurOS = NULL;
     198                fWasCurOS = true;
     199            }
     200            break;
     201        }
     202    DBGF_OS_WRITE_UNLOCK(pVM);
     203    if (!pOS)
     204    {
     205        Log(("DBGFR3OSDeregister: %s -> VERR_NOT_FOUND\n", pReg->szName));
     206        return VERR_NOT_FOUND;
     207    }
     208
     209    /*
     210     * Terminate it if it was the current OS, then invoke the
     211     * destructor and clean up.
     212     */
     213    if (fWasCurOS)
     214        pOS->pReg->pfnTerm(pVM, pOS->abData);
     215    if (pOS->pReg->pfnDestruct)
     216        pOS->pReg->pfnDestruct(pVM, pOS->abData);
     217    MMR3HeapFree(pOS);
     218
     219    return VINF_SUCCESS;
     220}
     221
     222
     223/**
     224 * Deregisters a guest OS digger previously registered by DBGFR3OSRegister.
     225 *
     226 * @returns VBox status code.
     227 *
     228 * @param   pVM     Pointer to the shared VM structure.
     229 * @param   pReg    The registration structure.
     230 * @thread  Any.
     231 */
     232VMMR3DECL(int)  DBGFR3OSDeregister(PVM pVM, PCDBGFOSREG pReg)
     233{
     234    /*
     235     * Validate input.
     236     */
     237    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     238    AssertPtrReturn(pReg, VERR_INVALID_POINTER);
     239    AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC);
     240    AssertReturn(pReg->u32EndMagic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC);
     241    AssertReturn(memchr(&pReg->szName[0], '\0', sizeof(pReg->szName)), VERR_INVALID_NAME);
     242
     243    DBGF_OS_READ_LOCK(pVM);
     244    PDBGFOS pOS;
     245    for (pOS = pVM->dbgf.s.pOSHead; pOS; pOS = pOS->pNext)
     246        if (pOS->pReg == pReg)
     247            break;
     248    DBGF_OS_READ_LOCK(pVM);
     249
     250    if (!pOS)
     251    {
     252        Log(("DBGFR3OSDeregister: %s -> VERR_NOT_FOUND\n", pReg->szName));
     253        return VERR_NOT_FOUND;
     254    }
     255
     256    /*
     257     * Pass it on to the EMT.
     258     */
     259    PVMREQ pReq;
     260    int rc = VMR3ReqCallU(pVM->pUVM, 0, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSDeregister, 2, pVM, pReg);
     261    if (RT_SUCCESS(rc))
     262        rc = pReq->iStatus;
     263    VMR3ReqFree(pReq);
     264
     265    return rc;
    153266}
    154267
     
    223336     */
    224337    PVMREQ pReq;
    225     int rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSDetect, 3, pVM, pszName, cchName);
     338    int rc = VMR3ReqCallU(pVM->pUVM, 0, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSDetect, 3, pVM, pszName, cchName);
    226339    if (RT_SUCCESS(rc))
    227340        rc = pReq->iStatus;
     
    307420     */
    308421    PVMREQ pReq;
    309     int rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSQueryNameAndVersion,
     422    int rc = VMR3ReqCallU(pVM->pUVM, 0, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)dbgfR3OSQueryNameAndVersion,
    310423                          5, pVM, pszName, cchName, pszVersion, cchVersion);
    311424    if (RT_SUCCESS(rc))
Note: See TracChangeset for help on using the changeset viewer.

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