VirtualBox

Changeset 55881 in vbox


Ignore:
Timestamp:
May 16, 2015 1:02:51 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100338
Message:

DBGF,DBGC: Moved the plug-ins from DBGC to DBGF so we can make use of them via IMachineDebugger.

Location:
trunk
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbg.h

    r44399 r55881  
    88
    99/*
    10  * Copyright (C) 2006-2013 Oracle Corporation
     10 * Copyright (C) 2006-2015 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4242RT_C_DECLS_BEGIN
    4343
     44
    4445#ifdef IN_RING3 /* The debugger stuff is ring-3 only. */
     46
     47/** @defgroup grp_dbgc     The Debugger Console API
     48 * @{
     49 */
    4550
    4651/** @def VBOX_WITH_DEBUGGER
     
    10961101DBGDECL(int)    DBGCTcpTerminate(PUVM pUVM, void *pvData);
    10971102
    1098 
    1099 /** @defgroup grp_dbgc_plug_in      The DBGC Plug-in Interface
    1100  * @{
    1101  */
    1102 
    1103 /** The plug-in module name prefix. */
    1104 #define DBGC_PLUG_IN_PREFIX         "DBGCPlugIn"
    1105 
    1106 /** The name of the plug-in entry point (FNDBGCPLUGIN) */
    1107 #define DBGC_PLUG_IN_ENTRYPOINT     "DBGCPlugInEntry"
    1108 
    1109 /**
    1110  * DBGC plug-in operations.
    1111  */
    1112 typedef enum DBGCPLUGINOP
    1113 {
    1114     /** The usual invalid first value. */
    1115     DBGCPLUGINOP_INVALID,
    1116     /** Initialize the plug-in, register all the stuff.
    1117      * The plug-in will be unloaded on failure.
    1118      * uArg: The VirtualBox version (major+minor). */
    1119     DBGCPLUGINOP_INIT,
    1120     /** Terminate the plug-ing, deregister all the stuff.
    1121      * The plug-in will be unloaded after this call regardless of the return
    1122      * code. */
    1123     DBGCPLUGINOP_TERM,
    1124     /** The usual 32-bit hack. */
    1125     DBGCPLUGINOP_32BIT_HACK = 0x7fffffff
    1126 } DBGCPLUGINOP;
    1127 
    1128 /**
    1129  * DBGC plug-in main entry point.
    1130  *
    1131  * @returns VBox status code.
    1132  *
    1133  * @param   enmOperation    The operation.
    1134  * @param   pUVM            The user mode VM handle. This may be NULL.
    1135  * @param   uArg            Extra argument.
    1136  */
    1137 typedef DECLCALLBACK(int) FNDBGCPLUGIN(DBGCPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
    1138 /** Pointer to a FNDBGCPLUGIN. */
    1139 typedef FNDBGCPLUGIN *PFNDBGCPLUGIN;
    1140 
    1141 /** @copydoc FNDBGCPLUGIN */
    1142 DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
     1103/** @} */
    11431104
    11441105#endif /* IN_RING3 */
    11451106
    1146 /** @} */
    1147 
    1148 
    11491107RT_C_DECLS_END
    11501108
  • trunk/include/VBox/vmm/dbgf.h

    r54218 r55881  
    17331733VMMR3DECL(int)      DBGFR3CoreWrite(PUVM pUVM, const char *pszFilename, bool fReplaceFile);
    17341734
     1735
     1736#ifdef IN_RING3
     1737/** @defgroup grp_dbgf_plug_in      The DBGF Plug-in Interface
     1738 * @{
     1739 */
     1740
     1741/** The plug-in module name prefix. */
     1742#define DBGF_PLUG_IN_PREFIX         "DbgPlugIn"
     1743
     1744/** The name of the plug-in entry point (FNDBGFPLUGIN) */
     1745#define DBGF_PLUG_IN_ENTRYPOINT     "DbgPlugInEntry"
     1746
     1747/**
     1748 * DBGF plug-in operations.
     1749 */
     1750typedef enum DBGFPLUGINOP
     1751{
     1752    /** The usual invalid first value. */
     1753    DBGFPLUGINOP_INVALID,
     1754    /** Initialize the plug-in for a VM, register all the stuff.
     1755     * The plug-in will be unloaded on failure.
     1756     * uArg: The full VirtualBox version, see VBox/version.h. */
     1757    DBGFPLUGINOP_INIT,
     1758    /** Terminate the plug-ing for a VM, deregister all the stuff.
     1759     * The plug-in will be unloaded after this call regardless of the return
     1760     * code. */
     1761    DBGFPLUGINOP_TERM,
     1762    /** The usual 32-bit hack. */
     1763    DBGFPLUGINOP_32BIT_HACK = 0x7fffffff
     1764} DBGFPLUGINOP;
     1765
     1766/**
     1767 * DBGF plug-in main entry point.
     1768 *
     1769 * @returns VBox status code.
     1770 *
     1771 * @param   enmOperation    The operation.
     1772 * @param   pUVM            The user mode VM handle. This may be NULL.
     1773 * @param   uArg            Extra argument.
     1774 */
     1775typedef DECLCALLBACK(int) FNDBGFPLUGIN(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
     1776/** Pointer to a FNDBGFPLUGIN. */
     1777typedef FNDBGFPLUGIN *PFNDBGFPLUGIN;
     1778
     1779/** @copydoc FNDBGFPLUGIN */
     1780DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg);
     1781
     1782VMMR3DECL(int)  DBGFR3PlugInLoad(PUVM pUVM, const char *pszPlugIn, char *pszActual, size_t cbActual, PRTERRINFO pErrInfo);
     1783VMMR3DECL(int)  DBGFR3PlugInUnload(PUVM pUVM, const char *pszName);
     1784VMMR3DECL(void) DBGFR3PlugInLoadAll(PUVM pUVM);
     1785VMMR3DECL(void) DBGFR3PlugInUnloadAll(PUVM pUVM);
     1786
    17351787/** @} */
     1788#endif /* IN_RING3 */
     1789
     1790
     1791/** @} */
    17361792
    17371793
  • trunk/src/VBox/Debugger/DBGCCommands.cpp

    r55767 r55881  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7070static FNDBGCCMD dbgcCmdLoadPlugIn;
    7171static FNDBGCCMD dbgcCmdUnloadPlugIn;
    72 static FNDBGCCMD dbgcCmdShowPlugIns;
    7372static FNDBGCCMD dbgcCmdHarakiri;
    7473static FNDBGCCMD dbgcCmdEcho;
     
    267266                                                                                                                                        "(after removing blanks) are comment. blank lines are ignored. Stops on failure." },
    268267    { "set",        2,        2,        &g_aArgSet[0],       RT_ELEMENTS(g_aArgSet),       0, dbgcCmdSet,       "<var> <value>",        "Sets a global variable." },
    269     { "showplugins",0,        0,        NULL,                0,                            0, dbgcCmdShowPlugIns,"",                     "List loaded plugins." },
    270268    { "showvars",   0,        0,        NULL,                0,                            0, dbgcCmdShowVars,  "",                     "List all the defined variables." },
    271269    { "stop",       0,        0,        NULL,                0,                            0, dbgcCmdStop,      "",                     "Stop execution." },
     
    17481746
    17491747/**
    1750  * Extracts the plugin name from a plugin specifier that may or may not include
    1751  * path and/or suffix.
    1752  *
    1753  * @returns VBox status code.
    1754  *
    1755  * @param   pszDst      Where to return the name. At least DBGCPLUGIN_MAX_NAME
    1756  *                      worth of buffer space.
    1757  * @param   pszPlugIn   The plugin specifier to parse.
    1758  */
    1759 static int dbgcPlugInExtractName(char *pszDst, const char *pszPlugIn)
    1760 {
    1761     /*
    1762      * Parse out the name stopping at the extension.
    1763      */
    1764     const char *pszName = RTPathFilename(pszPlugIn);
    1765     if (!pszName || !*pszName)
    1766         return VERR_INVALID_NAME;
    1767     if (!RTStrNICmp(pszName, DBGC_PLUG_IN_PREFIX, sizeof(DBGC_PLUG_IN_PREFIX) - 1))
    1768     {
    1769         pszName += sizeof(DBGC_PLUG_IN_PREFIX) - 1;
    1770         if (!*pszName)
    1771             return VERR_INVALID_NAME;
    1772     }
    1773 
    1774     int         ch;
    1775     size_t      cchName = 0;
    1776     while (   (ch = pszName[cchName]) != '\0'
    1777            && ch != '.')
    1778     {
    1779         if (    !RT_C_IS_ALPHA(ch)
    1780             &&  (   !RT_C_IS_DIGIT(ch)
    1781                  || cchName == 0))
    1782             return VERR_INVALID_NAME;
    1783         cchName++;
    1784     }
    1785 
    1786     if (cchName >= DBGCPLUGIN_MAX_NAME)
    1787         return VERR_OUT_OF_RANGE;
    1788 
    1789     /*
    1790      * We're very picky about the extension if there is no path.
    1791      */
    1792     if (    ch == '.'
    1793         &&  !RTPathHavePath(pszPlugIn)
    1794         &&  RTStrICmp(&pszName[cchName], RTLdrGetSuff()))
    1795         return VERR_INVALID_NAME;
    1796 
    1797     /*
    1798      * Copy it.
    1799      */
    1800     memcpy(pszDst, pszName, cchName);
    1801     pszDst[cchName] = '\0';
     1748 * @interface_method_impl{FNDBCCMD, The 'loadplugin' command.}
     1749 */
     1750static DECLCALLBACK(int) dbgcCmdLoadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
     1751{
     1752    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
     1753
     1754    /*
     1755     * Loop thru the plugin names.
     1756     */
     1757    for (unsigned i = 0; i < cArgs; i++)
     1758    {
     1759        char            szPlugIn[128];
     1760        RTERRINFOSTATIC ErrInfo;
     1761        szPlugIn[0] = '\0';
     1762        int rc = DBGFR3PlugInLoad(pDbgc->pUVM, paArgs[i].u.pszString, szPlugIn, sizeof(szPlugIn), RTErrInfoInitStatic(&ErrInfo));
     1763        if (RT_SUCCESS(rc))
     1764            DBGCCmdHlpPrintf(pCmdHlp, "Loaded plug-in '%s' (%s)\n", szPlugIn, paArgs[i].u.pszString);
     1765        else if (rc == VERR_ALREADY_EXISTS)
     1766            DBGCCmdHlpPrintf(pCmdHlp, "A plug-in named '%s' is already loaded\n", szPlugIn);
     1767        else if (szPlugIn[0])
     1768            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3PlugInLoad failed for '%s' ('%s'): %s",
     1769                                    szPlugIn, paArgs[i].u.pszString, ErrInfo.szMsg);
     1770        else
     1771            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3PlugInLoad failed for '%s': %s",
     1772                                    paArgs[i].u.pszString, ErrInfo.szMsg);
     1773    }
     1774
    18021775    return VINF_SUCCESS;
    18031776}
     
    18051778
    18061779/**
    1807  * Locate a plug-in in list.
    1808  *
    1809  * @returns Pointer to the plug-in tracking structure.
    1810  * @param   pDbgc               Pointer to the DBGC instance data.
    1811  * @param   pszName             The name of the plug-in we're looking for.
    1812  * @param   ppPrev              Where to optionally return the pointer to the
    1813  *                              previous list member.
    1814  */
    1815 static PDBGCPLUGIN dbgcPlugInLocate(PDBGC pDbgc, const char *pszName, PDBGCPLUGIN *ppPrev)
    1816 {
    1817     PDBGCPLUGIN pPrev = NULL;
    1818     PDBGCPLUGIN pCur  = pDbgc->pPlugInHead;
    1819     while (pCur)
    1820     {
    1821         if (!RTStrICmp(pCur->szName, pszName))
    1822         {
    1823             if (ppPrev)
    1824                 *ppPrev = pPrev;
    1825             return pCur;
    1826         }
    1827 
    1828         /* advance */
    1829         pPrev = pCur;
    1830         pCur  = pCur->pNext;
    1831     }
    1832     return NULL;
    1833 }
    1834 
    1835 
    1836 /**
    1837  * Try load the specified plug-in module.
    1838  *
    1839  * @returns VINF_SUCCESS on success, path error or loader error on failure.
    1840  *
    1841  * @param   pPlugIn     The plugin tracing record.
    1842  * @param   pszModule   Module name.
    1843  */
    1844 static int dbgcPlugInTryLoad(PDBGCPLUGIN pPlugIn, const char *pszModule)
    1845 {
    1846     /*
    1847      * Load it and try resolve the entry point.
    1848      */
    1849     int rc = RTLdrLoad(pszModule, &pPlugIn->hLdrMod);
    1850     if (RT_SUCCESS(rc))
    1851     {
    1852         rc = RTLdrGetSymbol(pPlugIn->hLdrMod, DBGC_PLUG_IN_ENTRYPOINT, (void **)&pPlugIn->pfnEntry);
     1780 * @interface_method_impl{FNDBCCMD, The 'unload' command.}
     1781 */
     1782static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
     1783{
     1784    PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
     1785
     1786    /*
     1787     * Loop thru the given plug-in names.
     1788     */
     1789    for (unsigned i = 0; i < cArgs; i++)
     1790    {
     1791        int rc = DBGFR3PlugInUnload(pDbgc->pUVM, paArgs[i].u.pszString);
    18531792        if (RT_SUCCESS(rc))
    1854             return VINF_SUCCESS;
    1855         LogRel(("DBGC: RTLdrGetSymbol('%s', '%s',) -> %Rrc\n", pszModule, DBGC_PLUG_IN_ENTRYPOINT, rc));
    1856 
    1857         RTLdrClose(pPlugIn->hLdrMod);
    1858         pPlugIn->hLdrMod = NIL_RTLDRMOD;
    1859     }
    1860     return rc;
    1861 }
    1862 
    1863 
    1864 /**
    1865  * RTPathTraverseList callback.
    1866  *
    1867  * @returns See FNRTPATHTRAVERSER.
    1868  *
    1869  * @param   pchPath     See FNRTPATHTRAVERSER.
    1870  * @param   cchPath     See FNRTPATHTRAVERSER.
    1871  * @param   pvUser1     The plug-in specifier.
    1872  * @param   pvUser2     The plug-in tracking record.
    1873  */
    1874 static DECLCALLBACK(int) dbgcPlugInLoadCallback(const char *pchPath, size_t cchPath, void *pvUser1, void *pvUser2)
    1875 {
    1876     PDBGCPLUGIN pPlugIn   = (PDBGCPLUGIN)pvUser2;
    1877     const char *pszPlugIn = (const char *)pvUser1;
    1878 
    1879     /*
    1880      * Join the path and the specified plug-in module name, first with the
    1881      * prefix and then without it.
    1882      */
    1883     size_t      cchModule = cchPath + 1 + strlen(pszPlugIn) + sizeof(DBGC_PLUG_IN_PREFIX) + 8;
    1884     char       *pszModule = (char *)alloca(cchModule);
    1885     AssertReturn(pszModule, VERR_TRY_AGAIN);
    1886     memcpy(pszModule, pchPath, cchPath);
    1887     pszModule[cchPath] = '\0';
    1888 
    1889     int rc = RTPathAppend(pszModule, cchModule, DBGC_PLUG_IN_PREFIX);
    1890     AssertRCReturn(rc, VERR_TRY_AGAIN);
    1891     strcat(pszModule, pszPlugIn);
    1892     rc = dbgcPlugInTryLoad(pPlugIn, pszModule);
    1893     if (RT_SUCCESS(rc))
    1894         return VINF_SUCCESS;
    1895 
    1896     pszModule[cchPath] = '\0';
    1897     rc = RTPathAppend(pszModule, cchModule, pszPlugIn);
    1898     AssertRCReturn(rc, VERR_TRY_AGAIN);
    1899     rc = dbgcPlugInTryLoad(pPlugIn, pszModule);
    1900     if (RT_SUCCESS(rc))
    1901         return VINF_SUCCESS;
    1902 
    1903     return VERR_TRY_AGAIN;
    1904 }
    1905 
    1906 
    1907 /**
    1908  * Loads a plug-in.
    1909  *
    1910  * @returns VBox status code. If pCmd is specified, it's the return from
    1911  *          DBGCCmdHlpFail.
    1912  * @param   pDbgc               The DBGC instance data.
    1913  * @param   pszName             The plug-in name.
    1914  * @param   pszPlugIn           The plug-in module name.
    1915  * @param   pCmd                The command pointer if invoked by the user, NULL
    1916  *                              if invoked from elsewhere.
    1917  */
    1918 static int dbgcPlugInLoad(PDBGC pDbgc, const char *pszName, const char *pszPlugIn, PCDBGCCMD pCmd)
    1919 {
    1920     PDBGCCMDHLP pCmdHlp = &pDbgc->CmdHlp;
    1921 
    1922     /*
    1923      * Try load it.  If specified with a path, we're assuming the user
    1924      * wants to load a plug-in from some specific location.  Otherwise
    1925      * search for it.
    1926      */
    1927     PDBGCPLUGIN pPlugIn = (PDBGCPLUGIN)RTMemAllocZ(sizeof(*pPlugIn));
    1928     if (!pPlugIn)
    1929         return pCmd
    1930              ? DBGCCmdHlpFail(pCmdHlp, pCmd, "out of memory\n")
    1931              : VERR_NO_MEMORY;
    1932     strcpy(pPlugIn->szName, pszName);
    1933 
    1934     int rc;
    1935     if (RTPathHavePath(pszPlugIn))
    1936         rc = dbgcPlugInTryLoad(pPlugIn, pszPlugIn);
    1937     else
    1938     {
    1939         /* 1. The private architecture directory. */
    1940         char szPath[4*_1K];
    1941         rc = RTPathAppPrivateArch(szPath, sizeof(szPath));
    1942         if (RT_SUCCESS(rc))
    1943             rc = RTPathTraverseList(szPath, '\0', dbgcPlugInLoadCallback, (void *)pszPlugIn, pPlugIn);
    1944         if (RT_FAILURE(rc))
    1945         {
    1946             /* 2. The DBGC PLUGIN_PATH variable. */
    1947             DBGCVAR PathVar;
    1948             int rc2 = DBGCCmdHlpEval(pCmdHlp, &PathVar, "$PLUGIN_PATH");
    1949             if (    RT_SUCCESS(rc2)
    1950                 &&  PathVar.enmType == DBGCVAR_TYPE_STRING)
    1951                 rc = RTPathTraverseList(PathVar.u.pszString, ';', dbgcPlugInLoadCallback, (void *)pszPlugIn, pPlugIn);
    1952             if (RT_FAILURE_NP(rc))
    1953             {
    1954                 /* 3. The DBGC_PLUGIN_PATH environment variable. */
    1955                 rc2 = RTEnvGetEx(RTENV_DEFAULT, "DBGC_PLUGIN_PATH", szPath, sizeof(szPath), NULL);
    1956                 if (RT_SUCCESS(rc2))
    1957                     rc = RTPathTraverseList(szPath, ';', dbgcPlugInLoadCallback, (void *)pszPlugIn, pPlugIn);
    1958             }
    1959         }
    1960     }
    1961     if (RT_FAILURE(rc))
    1962     {
    1963         RTMemFree(pPlugIn);
    1964         return pCmd
    1965             ? DBGCCmdHlpFail(pCmdHlp, pCmd, "could not find/load '%s'\n", pszPlugIn)
    1966             : rc;
    1967     }
    1968 
    1969     /*
    1970      * Try initialize it.
    1971      */
    1972     rc = pPlugIn->pfnEntry(DBGCPLUGINOP_INIT, pDbgc->pUVM, VBOX_VERSION);
    1973     if (RT_FAILURE(rc))
    1974     {
    1975         RTLdrClose(pPlugIn->hLdrMod);
    1976         RTMemFree(pPlugIn);
    1977         return pCmd
    1978             ? DBGCCmdHlpFail(pCmdHlp, pCmd, "initialization of plug-in '%s' failed with rc=%Rrc\n", pszPlugIn, rc)
    1979             : rc;
    1980     }
    1981 
    1982     /*
    1983      * Link it and we're good.
    1984      */
    1985     pPlugIn->pNext = pDbgc->pPlugInHead;
    1986     pDbgc->pPlugInHead = pPlugIn;
    1987     DBGCCmdHlpPrintf(pCmdHlp, "Loaded plug-in '%s'.\n", pPlugIn->szName);
     1793            DBGCCmdHlpPrintf(pCmdHlp, "Unloaded plug-in '%s'\n", paArgs[i].u.pszString);
     1794        else if (rc == VERR_NOT_FOUND)
     1795            return DBGCCmdHlpFail(pCmdHlp, pCmd, "'%s' was not found\n", paArgs[i].u.pszString);
     1796        else
     1797            return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3PlugInUnload failed for '%s'", paArgs[i].u.pszString);
     1798    }
     1799
    19881800    return VINF_SUCCESS;
    19891801}
    1990 
    1991 
    1992 
    1993 
    1994 /**
    1995  * Automatically load plug-ins from the architecture private directory of
    1996  * VirtualBox.
    1997  *
    1998  * This is called during console init.
    1999  *
    2000  * @param   pDbgc       The DBGC instance data.
    2001  */
    2002 void dbgcPlugInAutoLoad(PDBGC pDbgc)
    2003 {
    2004     /*
    2005      * Open the architecture specific directory with a filter on our prefix
    2006      * and names including a dot.
    2007      */
    2008     const char *pszSuff = RTLdrGetSuff();
    2009     size_t      cchSuff = strlen(pszSuff);
    2010 
    2011     char szPath[RTPATH_MAX];
    2012     int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - cchSuff);
    2013     AssertRCReturnVoid(rc);
    2014     size_t offDir = strlen(szPath);
    2015 
    2016     rc = RTPathAppend(szPath, sizeof(szPath) - cchSuff, DBGC_PLUG_IN_PREFIX "*");
    2017     AssertRCReturnVoid(rc);
    2018     strcat(szPath, pszSuff);
    2019 
    2020     PRTDIR pDir;
    2021     rc = RTDirOpenFiltered(&pDir, szPath, RTDIRFILTER_WINNT, 0);
    2022     if (RT_SUCCESS(rc))
    2023     {
    2024         /*
    2025          * Now read it and try load each of the plug-in modules.
    2026          */
    2027         RTDIRENTRY DirEntry;
    2028         while (RT_SUCCESS(RTDirRead(pDir, &DirEntry, NULL)))
    2029         {
    2030             szPath[offDir] = '\0';
    2031             rc = RTPathAppend(szPath, sizeof(szPath), DirEntry.szName);
    2032             if (RT_SUCCESS(rc))
    2033             {
    2034                 char szName[DBGCPLUGIN_MAX_NAME];
    2035                 rc = dbgcPlugInExtractName(szName, DirEntry.szName);
    2036                 if (RT_SUCCESS(rc))
    2037                     dbgcPlugInLoad(pDbgc, szName, szPath, NULL /*pCmd*/);
    2038             }
    2039         }
    2040 
    2041         RTDirClose(pDir);
    2042     }
    2043 }
    2044 
    2045 
    2046 /**
    2047  * @interface_method_impl{FNDBCCMD, The 'loadplugin' command.}
    2048  */
    2049 static DECLCALLBACK(int) dbgcCmdLoadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
    2050 {
    2051     PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    2052 
    2053     /*
    2054      * Loop thru the plugin names.
    2055      */
    2056     for (unsigned i = 0; i < cArgs; i++)
    2057     {
    2058         const char *pszPlugIn = paArgs[i].u.pszString;
    2059 
    2060         /* Extract the plug-in name. */
    2061         char szName[DBGCPLUGIN_MAX_NAME];
    2062         int rc = dbgcPlugInExtractName(szName, pszPlugIn);
    2063         if (RT_FAILURE(rc))
    2064             return DBGCCmdHlpFail(pCmdHlp, pCmd, "Malformed plug-in name: '%s'\n", pszPlugIn);
    2065 
    2066         /* Loaded? */
    2067         PDBGCPLUGIN pPlugIn = dbgcPlugInLocate(pDbgc, szName, NULL);
    2068         if (pPlugIn)
    2069             return DBGCCmdHlpFail(pCmdHlp, pCmd, "'%s' is already loaded\n", szName);
    2070 
    2071         /* Load it. */
    2072         rc = dbgcPlugInLoad(pDbgc, szName, pszPlugIn, pCmd);
    2073         if (RT_FAILURE(rc))
    2074             return rc;
    2075     }
    2076 
    2077     return VINF_SUCCESS;
    2078 }
    2079 
    2080 
    2081 /**
    2082  * Unload all plug-ins.
    2083  *
    2084  * @param   pDbgc       The DBGC instance data.
    2085  */
    2086 void dbgcPlugInUnloadAll(PDBGC pDbgc)
    2087 {
    2088     while (pDbgc->pPlugInHead)
    2089     {
    2090         PDBGCPLUGIN pPlugIn = pDbgc->pPlugInHead;
    2091         pDbgc->pPlugInHead = pPlugIn->pNext;
    2092 
    2093         if (    pDbgc->pVM /* prevents trouble during destruction. */
    2094             &&  pDbgc->pVM->enmVMState < VMSTATE_DESTROYING)
    2095         {
    2096             pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pUVM, 0);
    2097             RTLdrClose(pPlugIn->hLdrMod);
    2098         }
    2099         pPlugIn->hLdrMod = NIL_RTLDRMOD;
    2100 
    2101         RTMemFree(pPlugIn);
    2102     }
    2103 }
    2104 
    2105 
    2106 /**
    2107  * @interface_method_impl{FNDBCCMD, The 'unload' command.}
    2108  */
    2109 static DECLCALLBACK(int) dbgcCmdUnloadPlugIn(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
    2110 {
    2111     PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    2112 
    2113     /*
    2114      * Loop thru the plugin names.
    2115      */
    2116     for (unsigned i = 0; i < cArgs; i++)
    2117     {
    2118         const char *pszPlugIn = paArgs[i].u.pszString;
    2119 
    2120         /* Extract the plug-in name. */
    2121         char szName[DBGCPLUGIN_MAX_NAME];
    2122         int rc = dbgcPlugInExtractName(szName, pszPlugIn);
    2123         if (RT_FAILURE(rc))
    2124             return DBGCCmdHlpFail(pCmdHlp, pCmd, "Malformed plug-in name: '%s'\n", pszPlugIn);
    2125 
    2126         /* Loaded? */
    2127         PDBGCPLUGIN pPrevPlugIn;
    2128         PDBGCPLUGIN pPlugIn = dbgcPlugInLocate(pDbgc, szName, &pPrevPlugIn);
    2129         if (!pPlugIn)
    2130             return DBGCCmdHlpFail(pCmdHlp, pCmd, "'%s' is not\n", szName);
    2131 
    2132         /*
    2133          * Terminate and unload it.
    2134          */
    2135         pPlugIn->pfnEntry(DBGCPLUGINOP_TERM, pDbgc->pUVM, 0);
    2136         RTLdrClose(pPlugIn->hLdrMod);
    2137         pPlugIn->hLdrMod = NIL_RTLDRMOD;
    2138 
    2139         if (pPrevPlugIn)
    2140             pPrevPlugIn->pNext = pPlugIn->pNext;
    2141         else
    2142             pDbgc->pPlugInHead = pPlugIn->pNext;
    2143         RTMemFree(pPlugIn->pNext);
    2144         DBGCCmdHlpPrintf(pCmdHlp, "Unloaded plug-in '%s'\n", szName);
    2145     }
    2146 
    2147     return VINF_SUCCESS;
    2148 }
    2149 
    2150 
    2151 /**
    2152  * @interface_method_impl{FNDBCCMD, The 'showplugins' command.}
    2153  */
    2154 static DECLCALLBACK(int) dbgcCmdShowPlugIns(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs)
    2155 {
    2156     PDBGC       pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp);
    2157     PDBGCPLUGIN pPlugIn = pDbgc->pPlugInHead;
    2158     if (!pPlugIn)
    2159         return DBGCCmdHlpPrintf(pCmdHlp, "No plug-ins loaded\n");
    2160 
    2161     DBGCCmdHlpPrintf(pCmdHlp, "Plug-ins: %s", pPlugIn->szName);
    2162     for (;;)
    2163     {
    2164         pPlugIn = pPlugIn->pNext;
    2165         if (!pPlugIn)
    2166             break;
    2167         DBGCCmdHlpPrintf(pCmdHlp, ", %s", pPlugIn->szName);
    2168     }
    2169     return DBGCCmdHlpPrintf(pCmdHlp, "\n");
    2170 }
    2171 
    21721802
    21731803
  • trunk/src/VBox/Debugger/DBGCInternal.h

    r47569 r55881  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6464/** Pointer to named variable. */
    6565typedef DBGCNAMEDVAR *PDBGCNAMEDVAR;
    66 
    67 
    68 /** The max length of a plug-in name, zero terminator included. */
    69 #define DBGCPLUGIN_MAX_NAME     32
    70 
    71 /**
    72  * Plug-in tracking record.
    73  */
    74 typedef struct DBGCPLUGIN
    75 {
    76     /** Pointer to the next plug-in. */
    77     struct DBGCPLUGIN  *pNext;
    78     /** The loader handle.  */
    79     RTLDRMOD            hLdrMod;
    80     /** The plug-in entry point. */
    81     PFNDBGCPLUGIN       pfnEntry;
    82     /** The plug-in name (variable length).  */
    83     char                szName[DBGCPLUGIN_MAX_NAME];
    84 } DBGCPLUGIN;
    85 /** Pointer to plug-in tracking record. */
    86 typedef DBGCPLUGIN *PDBGCPLUGIN;
    8766
    8867
     
    158137     * and unset using command with those names. */
    159138    PDBGCNAMEDVAR      *papVars;
    160 
    161     /** The list of plug-in. (singly linked) */
    162     PDBGCPLUGIN         pPlugInHead;
    163139
    164140    /** The list of breakpoints. (singly linked) */
     
    398374void    dbgcInitCmdHlp(PDBGC pDbgc);
    399375
    400 void    dbgcPlugInAutoLoad(PDBGC pDbgc);
    401 void    dbgcPlugInUnloadAll(PDBGC pDbgc);
    402 
    403376/* For tstDBGCParser: */
    404377int     dbgcCreate(PDBGC *ppDbgc, PDBGCBACK pBack, unsigned fFlags);
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r46156 r55881  
    968968    }
    969969
    970     /* Unload all plug-ins. */
    971     dbgcPlugInUnloadAll(pDbgc);
    972 
    973970    /* Detach from the VM. */
    974971    if (pDbgc->pUVM)
     
    10501047    {
    10511048        if (pVM)
    1052             dbgcPlugInAutoLoad(pDbgc);
     1049            DBGFR3PlugInLoadAll(pDbgc->pUVM);
    10531050        rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "VBoxDbg> ");
    10541051        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Debugger/DBGPlugInDiggers.cpp

    r49044 r55881  
    11/* $Id$ */
    22/** @file
    3  * DBGPlugInDiggers - Debugger and Guest OS Digger Plug-in.
     3 * DbfPlugInDiggers - Debugger and Guest OS Digger Plug-in.
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828
    2929
    30 DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg)
     30DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGINOP enmOperation, PUVM pUVM, uintptr_t uArg)
    3131{
    3232    static PCDBGFOSREG s_aPlugIns[] =
     
    4242    switch (enmOperation)
    4343    {
    44         case DBGCPLUGINOP_INIT:
     44        case DBGFPLUGINOP_INIT:
    4545        {
    4646            if (uArg != VBOX_VERSION)
     
    6161        }
    6262
    63         case DBGCPLUGINOP_TERM:
     63        case DBGFPLUGINOP_TERM:
    6464        {
    6565            for (unsigned i = 0; i < RT_ELEMENTS(s_aPlugIns); i++)
  • trunk/src/VBox/Debugger/Makefile.kmk

    r55793 r55881  
    5454# The diggers plug-in.
    5555#
    56 DLLS += DBGCPlugInDiggers
    57 DBGCPlugInDiggers_TEMPLATE = VBOXR3
    58 DBGCPlugInDiggers_SOURCES = \
     56DLLS += DbgPlugInDiggers
     57DbgPlugInDiggers_TEMPLATE = VBOXR3
     58DbgPlugInDiggers_SOURCES = \
    5959        DBGPlugInDiggers.cpp \
    6060        DBGPlugInDarwin.cpp \
     
    6464        DBGPlugInOS2.cpp \
    6565        DBGPlugInCommonELF.cpp
    66 DBGCPlugInDiggers_LIBS = \
     66DbgPlugInDiggers_LIBS = \
    6767        $(if-expr "$(LIB_VMM)" == "$(VBOX_LIB_VMM_LAZY)",$(LIB_REM),) \
    6868        $(VBOX_LIB_VMM_LAZY) \
    6969        $(LIB_RUNTIME)
    70 $(call VBOX_SET_VER_INFO_DLL,DBGCPlugInDiggers,VirtualBox Debugger Guest OS Digger Plug-in)
     70$(call VBOX_SET_VER_INFO_DLL,DbgPlugInDiggers,VirtualBox Debugger Guest OS Digger Plug-in)
    7171
    7272
  • trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp

    r54218 r55881  
    322322}
    323323
     324VMMR3DECL(int)  DBGFR3PlugInLoad(PUVM pUVM, const char *pszPlugIn, char *pszActual, size_t cbActual, PRTERRINFO pErrInfo)
     325{
     326    return VERR_INTERNAL_ERROR;
     327}
     328VMMR3DECL(int)  DBGFR3PlugInUnload(PUVM pUVM, const char *pszName)
     329{
     330    return VERR_INTERNAL_ERROR;
     331}
     332VMMR3DECL(void) DBGFR3PlugInLoadAll(PUVM pUVM)
     333{
     334}
     335
    324336
    325337//////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/VMM/Makefile.kmk

    r55789 r55881  
    144144        VMMR3/DBGFMem.cpp \
    145145        VMMR3/DBGFOS.cpp \
     146        VMMR3/DBGFR3PlugIn.cpp \
    146147        VMMR3/DBGFReg.cpp \
    147148        VMMR3/DBGFStack.cpp \
  • trunk/src/VBox/VMM/VMMR3/DBGF.cpp

    r54218 r55881  
    141141    AssertCompile(sizeof(pUVM->aCpus[0].dbgf.s) <= sizeof(pUVM->aCpus[0].dbgf.padding));
    142142
    143     int rc = dbgfR3InfoInit(pUVM);
     143    /*
     144     * The usual sideways mountain climbing style of init:
     145     */
     146    int rc = dbgfR3InfoInit(pUVM); /* (First, initalizes the shared critical section.) */
    144147    if (RT_SUCCESS(rc))
     148    {
    145149        rc = dbgfR3TraceInit(pVM);
    146     if (RT_SUCCESS(rc))
    147         rc = dbgfR3RegInit(pUVM);
    148     if (RT_SUCCESS(rc))
    149         rc = dbgfR3AsInit(pUVM);
    150     if (RT_SUCCESS(rc))
    151         rc = dbgfR3BpInit(pVM);
    152     if (RT_SUCCESS(rc))
    153         rc = dbgfR3OSInit(pUVM);
     150        if (RT_SUCCESS(rc))
     151        {
     152            rc = dbgfR3RegInit(pUVM);
     153            if (RT_SUCCESS(rc))
     154            {
     155                rc = dbgfR3AsInit(pUVM);
     156                if (RT_SUCCESS(rc))
     157                {
     158                    rc = dbgfR3BpInit(pVM);
     159                    if (RT_SUCCESS(rc))
     160                    {
     161                        rc = dbgfR3OSInit(pUVM);
     162                        if (RT_SUCCESS(rc))
     163                        {
     164                            rc = dbgfR3PlugInInit(pUVM);
     165                            if (RT_SUCCESS(rc))
     166                            {
     167                                return VINF_SUCCESS;
     168                            }
     169                            dbgfR3OSTerm(pUVM);
     170                        }
     171                    }
     172                    dbgfR3AsTerm(pUVM);
     173                }
     174                dbgfR3RegTerm(pUVM);
     175            }
     176            dbgfR3TraceTerm(pVM);
     177        }
     178        dbgfR3InfoTerm(pUVM);
     179    }
    154180    return rc;
    155181}
     
    166192    PUVM pUVM = pVM->pUVM;
    167193
     194    dbgfR3PlugInTerm(pUVM);
    168195    dbgfR3OSTerm(pUVM);
    169196    dbgfR3AsTerm(pUVM);
  • trunk/src/VBox/VMM/VMMR3/DBGFInfo.cpp

    r44399 r55881  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7979 * Initialize the info handlers.
    8080 *
     81 * This is called first during the DBGF init process and thus does the shared
     82 * critsect init.
     83 *
    8184 * @returns VBox status code.
    8285 * @param   pUVM        The user mode VM handle.
     
    8790     * Make sure we already didn't initialized in the lazy manner.
    8891     */
    89     if (RTCritSectIsInitialized(&pUVM->dbgf.s.InfoCritSect))
     92    if (RTCritSectRwIsInitialized(&pUVM->dbgf.s.CritSect))
    9093        return VINF_SUCCESS;
    9194
     
    9396     * Initialize the crit sect.
    9497     */
    95     int rc = RTCritSectInit(&pUVM->dbgf.s.InfoCritSect);
     98    int rc = RTCritSectRwInit(&pUVM->dbgf.s.CritSect);
    9699    AssertRCReturn(rc, rc);
    97100
     
    117120     * Delete the crit sect.
    118121     */
    119     int rc = RTCritSectDelete(&pUVM->dbgf.s.InfoCritSect);
     122    int rc = RTCritSectRwDelete(&pUVM->dbgf.s.CritSect);
    120123    AssertRC(rc);
    121124    return rc;
     
    209212/**
    210213 * Handle registration worker.
     214 *
    211215 * This allocates the structure, initializes the common fields and inserts into the list.
    212216 * Upon successful return the we're inside the crit sect and the caller must leave it.
     
    245249        /* lazy init */
    246250        rc = VINF_SUCCESS;
    247         if (!RTCritSectIsInitialized(&pUVM->dbgf.s.InfoCritSect))
     251        if (!RTCritSectRwIsInitialized(&pUVM->dbgf.s.CritSect))
    248252            rc = dbgfR3InfoInit(pUVM);
    249253        if (RT_SUCCESS(rc))
     
    252256             * Insert in alphabetical order.
    253257             */
    254             rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     258            rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect);
    255259            AssertRC(rc);
    256260            PDBGFINFO pPrev = NULL;
     
    308312        pInfo->u.Dev.pfnHandler = pfnHandler;
    309313        pInfo->u.Dev.pDevIns = pDevIns;
    310         RTCritSectLeave(&pVM->pUVM->dbgf.s.InfoCritSect);
     314        RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
    311315    }
    312316
     
    346350        pInfo->u.Drv.pfnHandler = pfnHandler;
    347351        pInfo->u.Drv.pDrvIns = pDrvIns;
    348         RTCritSectLeave(&pVM->pUVM->dbgf.s.InfoCritSect);
     352        RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
    349353    }
    350354
     
    398402        pInfo->enmType = DBGFINFOTYPE_INT;
    399403        pInfo->u.Int.pfnHandler = pfnHandler;
    400         RTCritSectLeave(&pVM->pUVM->dbgf.s.InfoCritSect);
     404        RTCritSectRwLeaveExcl(&pVM->pUVM->dbgf.s.CritSect);
    401405    }
    402406
     
    437441        pInfo->u.Ext.pfnHandler = pfnHandler;
    438442        pInfo->u.Ext.pvUser = pvUser;
    439         RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     443        RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
    440444    }
    441445
     
    467471     * Enumerate the info handlers and free the requested entries.
    468472     */
    469     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect); AssertRC(rc);
     473    int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rc);
    470474    rc = VERR_FILE_NOT_FOUND;
    471475    PDBGFINFO pPrev = NULL;
     
    509513        rc = VINF_SUCCESS;
    510514    }
    511     int rc2 = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     515    int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
    512516    AssertRC(rc2);
    513517    AssertRC(rc);
     
    539543     * Enumerate the info handlers and free the requested entries.
    540544     */
    541     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect); AssertRC(rc);
     545    int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rc);
    542546    rc = VERR_FILE_NOT_FOUND;
    543547    PDBGFINFO pPrev = NULL;
     
    581585        rc = VINF_SUCCESS;
    582586    }
    583     int rc2 = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     587    int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
    584588    AssertRC(rc2);
    585589    AssertRC(rc);
     
    608612     */
    609613    size_t cchName = strlen(pszName);
    610     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     614    int rc = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect);
    611615    AssertRC(rc);
    612616    rc = VERR_FILE_NOT_FOUND;
     
    626630            break;
    627631        }
    628     int rc2 = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     632    int rc2 = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect);
    629633    AssertRC(rc2);
    630634    AssertRC(rc);
     
    694698     */
    695699    size_t cchName = strlen(pszName);
    696     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     700    int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
    697701    AssertRC(rc);
    698702    PDBGFINFO pInfo = pUVM->dbgf.s.pInfoFirst;
     
    705709        /*
    706710         * Found it.
    707          *      Make a copy of it on the stack so we can leave the crit sect.
    708          *      Switch on the type and invoke the handler.
    709711         */
    710         DBGFINFO Info = *pInfo;
    711         rc = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
    712         AssertRC(rc);
    713712        rc = VINF_SUCCESS;
    714         switch (Info.enmType)
     713        switch (pInfo->enmType)
    715714        {
    716715            case DBGFINFOTYPE_DEV:
    717                 if (Info.fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
    718                     rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)Info.u.Dev.pfnHandler, 3, Info.u.Dev.pDevIns, pHlp, pszArgs);
     716                if (pInfo->fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
     717                    rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)pInfo->u.Dev.pfnHandler, 3, pInfo->u.Dev.pDevIns, pHlp, pszArgs);
    719718                else
    720                     Info.u.Dev.pfnHandler(Info.u.Dev.pDevIns, pHlp, pszArgs);
     719                    pInfo->u.Dev.pfnHandler(pInfo->u.Dev.pDevIns, pHlp, pszArgs);
    721720                break;
    722721
    723722            case DBGFINFOTYPE_DRV:
    724                 if (Info.fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
    725                     rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)Info.u.Drv.pfnHandler, 3, Info.u.Drv.pDrvIns, pHlp, pszArgs);
     723                if (pInfo->fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
     724                    rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)pInfo->u.Drv.pfnHandler, 3, pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
    726725                else
    727                     Info.u.Drv.pfnHandler(Info.u.Drv.pDrvIns, pHlp, pszArgs);
     726                    pInfo->u.Drv.pfnHandler(pInfo->u.Drv.pDrvIns, pHlp, pszArgs);
    728727                break;
    729728
     
    731730                if (RT_VALID_PTR(pUVM->pVM))
    732731                {
    733                     if (Info.fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
    734                         rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)Info.u.Int.pfnHandler, 3, pUVM->pVM, pHlp, pszArgs);
     732                    if (pInfo->fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
     733                        rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)pInfo->u.Int.pfnHandler, 3, pUVM->pVM, pHlp, pszArgs);
    735734                    else
    736                         Info.u.Int.pfnHandler(pUVM->pVM, pHlp, pszArgs);
     735                        pInfo->u.Int.pfnHandler(pUVM->pVM, pHlp, pszArgs);
    737736                }
    738737                else
     
    741740
    742741            case DBGFINFOTYPE_EXT:
    743                 if (Info.fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
    744                     rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)Info.u.Ext.pfnHandler, 3, Info.u.Ext.pvUser, pHlp, pszArgs);
     742                if (pInfo->fFlags & DBGFINFO_FLAGS_RUN_ON_EMT)
     743                    rc = VMR3ReqCallVoidWaitU(pUVM, idCpu, (PFNRT)pInfo->u.Ext.pfnHandler, 3, pInfo->u.Ext.pvUser, pHlp, pszArgs);
    745744                else
    746                     Info.u.Ext.pfnHandler(Info.u.Ext.pvUser, pHlp, pszArgs);
     745                    pInfo->u.Ext.pfnHandler(pInfo->u.Ext.pvUser, pHlp, pszArgs);
    747746                break;
    748747
    749748            default:
    750                 AssertMsgFailedReturn(("Invalid info type enmType=%d\n", Info.enmType), VERR_IPE_NOT_REACHED_DEFAULT_CASE);
     749                AssertMsgFailedReturn(("Invalid info type enmType=%d\n", pInfo->enmType), VERR_IPE_NOT_REACHED_DEFAULT_CASE);
    751750        }
     751        int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
     752        AssertRC(rc2);
    752753    }
    753754    else
    754755    {
    755         rc = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     756        rc = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
    756757        AssertRC(rc);
    757758        rc = VERR_FILE_NOT_FOUND;
     
    867868     * Note! We won't leave the critical section here...
    868869     */
    869     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     870    int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
    870871    AssertRC(rc);
    871872    rc = VWRN_NOT_FOUND;
     
    915916        }
    916917    }
    917     int rc2 = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     918    int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
    918919    AssertRC(rc2);
    919920
     
    947948     * Enter and enumerate.
    948949     */
    949     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     950    int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
    950951    AssertRC(rc);
    951952
     
    957958     * Leave and exit.
    958959     */
    959     int rc2 = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     960    int rc2 = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
    960961    AssertRC(rc2);
    961962
     
    980981     */
    981982    PUVM pUVM = pVM->pUVM;
    982     int rc = RTCritSectEnter(&pUVM->dbgf.s.InfoCritSect);
     983    int rc = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect);
    983984    AssertRC(rc);
    984985
     
    10071008     * Leave and exit.
    10081009     */
    1009     rc = RTCritSectLeave(&pUVM->dbgf.s.InfoCritSect);
     1010    rc = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect);
    10101011    AssertRC(rc);
    10111012}
  • trunk/src/VBox/VMM/VMMR3/DBGFOS.cpp

    r54218 r55881  
    3838
    3939#define DBGF_OS_READ_LOCK(pUVM) \
    40     do { int rcLock = RTCritSectRwEnterShared(&pUVM->dbgf.s.OSCritSect); AssertRC(rcLock); } while (0)
     40    do { int rcLock = RTCritSectRwEnterShared(&pUVM->dbgf.s.CritSect); AssertRC(rcLock); } while (0)
    4141#define DBGF_OS_READ_UNLOCK(pUVM) \
    42     do { int rcLock = RTCritSectRwLeaveShared(&pUVM->dbgf.s.OSCritSect); AssertRC(rcLock); } while (0)
     42    do { int rcLock = RTCritSectRwLeaveShared(&pUVM->dbgf.s.CritSect); AssertRC(rcLock); } while (0)
    4343
    4444#define DBGF_OS_WRITE_LOCK(pUVM) \
    45     do { int rcLock = RTCritSectRwEnterExcl(&pUVM->dbgf.s.OSCritSect); AssertRC(rcLock); } while (0)
     45    do { int rcLock = RTCritSectRwEnterExcl(&pUVM->dbgf.s.CritSect); AssertRC(rcLock); } while (0)
    4646#define DBGF_OS_WRITE_UNLOCK(pUVM) \
    47     do { int rcLock = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.OSCritSect); AssertRC(rcLock); } while (0)
     47    do { int rcLock = RTCritSectRwLeaveExcl(&pUVM->dbgf.s.CritSect); AssertRC(rcLock); } while (0)
    4848
    4949
     
    9393int dbgfR3OSInit(PUVM pUVM)
    9494{
    95     return RTCritSectRwInit(&pUVM->dbgf.s.OSCritSect);
     95    return VINF_SUCCESS;
    9696}
    9797
     
    104104void dbgfR3OSTerm(PUVM pUVM)
    105105{
    106     RTCritSectRwDelete(&pUVM->dbgf.s.OSCritSect);
     106    DBGF_OS_WRITE_LOCK(pUVM);
    107107
    108108    /*
     
    135135        MMR3HeapFree(pOS);
    136136    }
     137
     138    DBGF_OS_WRITE_UNLOCK(pUVM);
    137139}
    138140
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r54763 r55881  
    24902490        RTLogFlags(NULL, "nodisabled nobuffered");
    24912491#endif
    2492 #ifdef VBOX_WITH_STATISTICS
    2493         STAMR3Dump(pUVM, "*");
    2494 #else
     2492//#ifdef VBOX_WITH_STATISTICS
     2493//        STAMR3Dump(pUVM, "*");
     2494//#else
    24952495        LogRel(("************************* Statistics *************************\n"));
    24962496        STAMR3DumpToReleaseLog(pUVM, "*");
    24972497        LogRel(("********************* End of statistics **********************\n"));
    2498 #endif
     2498//#endif
    24992499
    25002500        /*
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r54218 r55881  
    185185
    186186
     187
    187188/**
    188189 * Converts a DBGF pointer into a VM pointer.
     
    317318    bool                        afAlignment2[3];
    318319
     320    /** Critical section protecting the Guest OS Digger data, the info handlers
     321     * and the plugins.  These share to give the best possible plugin unload
     322     * race protection. */
     323    RTCRITSECTRW                CritSect;
     324    /** Head of the LIFO of loaded DBGF plugins. */
     325    R3PTRTYPE(struct DBGFPLUGIN *) pPlugInHead;
    319326    /** The current Guest OS digger. */
    320327    R3PTRTYPE(PDBGFOS)          pCurOS;
    321328    /** The head of the Guest OS digger instances. */
    322329    R3PTRTYPE(PDBGFOS)          pOSHead;
    323     /** Critical section protecting the Guest OS Digger data. */
    324     RTCRITSECTRW                OSCritSect;
    325 
    326330    /** List of registered info handlers. */
    327331    R3PTRTYPE(PDBGFINFO)        pInfoFirst;
    328     /** Critical section protecting the above list. */
    329     RTCRITSECT                  InfoCritSect;
    330332
    331333} DBGFUSERPERVM;
     334typedef DBGFUSERPERVM *PDBGFUSERPERVM;
     335typedef DBGFUSERPERVM const *PCDBGFUSERPERVM;
    332336
    333337/**
     
    356360void dbgfR3TraceRelocate(PVM pVM);
    357361void dbgfR3TraceTerm(PVM pVM);
     362int  dbgfR3PlugInInit(PUVM pUVM);
     363void dbgfR3PlugInTerm(PUVM pUVM);
    358364
    359365
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