VirtualBox

Changeset 39650 in vbox


Ignore:
Timestamp:
Dec 16, 2011 11:27:51 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75451
Message:

DBGF,Main,VBoxManage: added target logger prefixes (release:/debug:). Implemented logger modifier methods in IMachineDebugger. Exposed these methods in VBoxManage debugvm.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp

    r35550 r39650  
    150150    return RTEXITCODE_SUCCESS;
    151151}
     152
     153/**
     154 * Handles the log sub-command.
     155 *
     156 * @returns Suitable exit code.
     157 * @param   pArgs               The handler arguments.
     158 * @param   pDebugger           Pointer to the debugger interface.
     159 * @param   pszSubCmd           The sub command.
     160 */
     161static RTEXITCODE handleDebugVM_LogXXXX(HandlerArg *pArgs, IMachineDebugger *pDebugger, const char *pszSubCmd)
     162{
     163    /*
     164     * Parse arguments.
     165     */
     166    bool                        fRelease = false;
     167    com::Utf8Str                strSettings;
     168
     169    RTGETOPTSTATE               GetState;
     170    RTGETOPTUNION               ValueUnion;
     171    static const RTGETOPTDEF    s_aOptions[] =
     172    {
     173        { "--release",      'r', RTGETOPT_REQ_NOTHING },
     174    };
     175    int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/);
     176    AssertRCReturn(rc, RTEXITCODE_FAILURE);
     177
     178    while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
     179    {
     180        switch (rc)
     181        {
     182            case 'r':
     183                fRelease = true;
     184                break;
     185
     186            case 'd':
     187                fRelease = false;
     188                break;
     189
     190            case VINF_GETOPT_NOT_OPTION:
     191                if (strSettings.length() == 0)
     192                    strSettings = ValueUnion.psz;
     193                else
     194                {
     195                    strSettings.append(' ');
     196                    strSettings.append(ValueUnion.psz);
     197                }
     198                break;
     199
     200            default:
     201                return errorGetOpt(USAGE_DEBUGVM, rc, &ValueUnion);
     202        }
     203    }
     204
     205    if (fRelease)
     206    {
     207        com::Utf8Str strTmp(strSettings);
     208        strSettings = "release: ";
     209        strSettings.append(strTmp);
     210    }
     211
     212    com::Bstr bstrSettings(strSettings);
     213    if (!strcmp(pszSubCmd, "log"))
     214        CHECK_ERROR2_RET(pDebugger, ModifyLogGroups(bstrSettings.raw()), RTEXITCODE_FAILURE);
     215    else if (!strcmp(pszSubCmd, "logdest"))
     216        CHECK_ERROR2_RET(pDebugger, ModifyLogDestinations(bstrSettings.raw()), RTEXITCODE_FAILURE);
     217    else if (!strcmp(pszSubCmd, "logflags"))
     218        CHECK_ERROR2_RET(pDebugger, ModifyLogFlags(bstrSettings.raw()), RTEXITCODE_FAILURE);
     219    else
     220        AssertFailedReturn(RTEXITCODE_FAILURE);
     221
     222    return RTEXITCODE_SUCCESS;
     223}
     224
    152225
    153226/**
     
    442515            else if (!strcmp(pszSubCmd, "injectnmi"))
    443516                rcExit = handleDebugVM_InjectNMI(pArgs, ptrDebugger);
     517            else if (!strcmp(pszSubCmd, "log"))
     518                rcExit = handleDebugVM_LogXXXX(pArgs, ptrDebugger, pszSubCmd);
     519            else if (!strcmp(pszSubCmd, "logdest"))
     520                rcExit = handleDebugVM_LogXXXX(pArgs, ptrDebugger, pszSubCmd);
     521            else if (!strcmp(pszSubCmd, "logflags"))
     522                rcExit = handleDebugVM_LogXXXX(pArgs, ptrDebugger, pszSubCmd);
    444523            else if (!strcmp(pszSubCmd, "osdetect"))
    445524                rcExit = handleDebugVM_OSDetect(pArgs, ptrDebugger);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r39169 r39650  
    645645                     "                            info <item> [args] |\n"
    646646                     "                            injectnmi |\n"
     647                     "                            log [--release|--debug] <settings> ...|\n"
     648                     "                            logdest [--release|--debug] <settings> ...|\n"
     649                     "                            logflags [--release|--debug] <settings> ...|\n"
    647650                     "                            osdetect |\n"
    648651                     "                            osinfo |\n"
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r39450 r39650  
    91589158        Retrieves status, exit code and the exit reason of a formerly started
    91599159        guest process. If a guest process exited or got terminated this function
    9160         returns its final status and removes this process from the list of 
     9160        returns its final status and removes this process from the list of
    91619161        known guest processes for further retrieval.
    91629162
     
    1325713257    <method name="modifyLogGroups">
    1325813258      <desc>
    13259         Modifies the group settings of the debug logger.
    13260 
    13261         This feature is not implemented in the 4.0.0 release but may show up
    13262         in a dot release.
     13259        Modifies the group settings of the debug or release logger.
    1326313260      </desc>
    1326413261      <param name="settings" type="wstring" dir="in">
    13265         <desc>The group settings string. See iprt/log.h for details.</desc>
     13262        <desc>
     13263          The group settings string. See iprt/log.h for details. To target the
     13264          release logger, prefix the string with "release:".
     13265        </desc>
    1326613266      </param>
    1326713267    </method>
     
    1326913269    <method name="modifyLogFlags">
    1327013270      <desc>
    13271         Modifies the debug logger flags.
    13272 
    13273         This feature is not implemented in the 4.0.0 release but may show up
    13274         in a dot release.
     13271        Modifies the debug or release logger flags.
    1327513272      </desc>
    1327613273      <param name="settings" type="wstring" dir="in">
    13277         <desc>The flags settings string. See iprt/log.h for details.</desc>
     13274        <desc>
     13275          The flags settings string. See iprt/log.h for details. To target the
     13276          release logger, prefix the string with "release:".
     13277        </desc>
    1327813278      </param>
    1327913279    </method>
     
    1328113281    <method name="modifyLogDestinations">
    1328213282      <desc>
    13283         Modifies the debug logger destinations.
    13284 
    13285         This feature is not implemented in the 4.0.0 release but may show up
    13286         in a dot release.
     13283        Modifies the debug or release logger destinations.
    1328713284      </desc>
    1328813285      <param name="settings" type="wstring" dir="in">
    13289         <desc>The destination settings string. See iprt/log.h for details.</desc>
     13286        <desc>
     13287          The destination settings string. See iprt/log.h for details. To target the
     13288          release logger, prefix the string with "release:".
     13289        </desc>
    1329013290      </param>
    1329113291    </method>
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r38324 r39650  
    963963STDMETHODIMP MachineDebugger::ModifyLogFlags(IN_BSTR a_bstrSettings)
    964964{
    965     ReturnComNotImplemented();
     965    CheckComArgStrNotEmptyOrNull(a_bstrSettings);
     966    Utf8Str strSettings(a_bstrSettings);
     967
     968    LogFlowThisFunc(("a_bstrSettings=%s\n", strSettings.c_str()));
     969    AutoCaller autoCaller(this);
     970    HRESULT hrc = autoCaller.rc();
     971    if (SUCCEEDED(hrc))
     972    {
     973        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     974        Console::SafeVMPtr ptrVM(mParent);
     975        hrc = ptrVM.rc();
     976        if (SUCCEEDED(hrc))
     977        {
     978            int vrc = DBGFR3LogModifyFlags(ptrVM, strSettings.c_str());
     979            if (RT_SUCCESS(vrc))
     980                hrc = S_OK;
     981            else
     982                hrc = setError(E_FAIL, tr("DBGFR3LogModifyFlags failed with %Rrc"), vrc);
     983        }
     984    }
     985    return hrc;
    966986}
    967987
    968988STDMETHODIMP MachineDebugger::ModifyLogGroups(IN_BSTR a_bstrSettings)
    969989{
    970     ReturnComNotImplemented();
     990    CheckComArgStrNotEmptyOrNull(a_bstrSettings);
     991    Utf8Str strSettings(a_bstrSettings);
     992
     993    LogFlowThisFunc(("a_bstrSettings=%s\n", strSettings.c_str()));
     994    AutoCaller autoCaller(this);
     995    HRESULT hrc = autoCaller.rc();
     996    if (SUCCEEDED(hrc))
     997    {
     998        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     999        Console::SafeVMPtr ptrVM(mParent);
     1000        hrc = ptrVM.rc();
     1001        if (SUCCEEDED(hrc))
     1002        {
     1003            int vrc = DBGFR3LogModifyGroups(ptrVM, strSettings.c_str());
     1004            if (RT_SUCCESS(vrc))
     1005                hrc = S_OK;
     1006            else
     1007                hrc = setError(E_FAIL, tr("DBGFR3LogModifyGroups failed with %Rrc"), vrc);
     1008        }
     1009    }
     1010    return hrc;
    9711011}
    9721012
    9731013STDMETHODIMP MachineDebugger::ModifyLogDestinations(IN_BSTR a_bstrSettings)
    9741014{
    975     ReturnComNotImplemented();
     1015    CheckComArgStrNotEmptyOrNull(a_bstrSettings);
     1016    Utf8Str strSettings(a_bstrSettings);
     1017
     1018    LogFlowThisFunc(("a_bstrSettings=%s\n", strSettings.c_str()));
     1019    AutoCaller autoCaller(this);
     1020    HRESULT hrc = autoCaller.rc();
     1021    if (SUCCEEDED(hrc))
     1022    {
     1023        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1024        Console::SafeVMPtr ptrVM(mParent);
     1025        hrc = ptrVM.rc();
     1026        if (SUCCEEDED(hrc))
     1027        {
     1028            int vrc = DBGFR3LogModifyDestinations(ptrVM, strSettings.c_str());
     1029            if (RT_SUCCESS(vrc))
     1030                hrc = S_OK;
     1031            else
     1032                hrc = setError(E_FAIL, tr("DBGFR3LogModifyDestinations failed with %Rrc"), vrc);
     1033        }
     1034    }
     1035    return hrc;
    9761036}
    9771037
  • trunk/src/VBox/VMM/VMMR3/DBGFLog.cpp

    r38838 r39650  
    2626#include <VBox/err.h>
    2727#include <iprt/assert.h>
     28#include <iprt/string.h>
    2829
    2930
     
    3738
    3839/**
     40 * Checkes for logger prefixes and selects the right logger.
     41 *
     42 * @returns Target logger.
     43 * @param   ppsz                Pointer to the string pointer.
     44 */
     45static PRTLOGGER dbgfR3LogResolvedLogger(const char **ppsz)
     46{
     47    PRTLOGGER   pLogger;
     48    const char *psz = *ppsz;
     49    if (!strncmp(psz, "release:", sizeof("release:") - 1))
     50    {
     51        *ppsz += sizeof("release:") - 1;
     52        pLogger = RTLogRelDefaultInstance();
     53    }
     54    else
     55    {
     56        if (!strncmp(psz, "debug:", sizeof("debug:") - 1))
     57            *ppsz += sizeof("debug:") - 1;
     58        pLogger = RTLogDefaultInstance();
     59    }
     60    return pLogger;
     61}
     62
     63
     64/**
    3965 * Changes the logger group settings.
    4066 *
     
    4268 * @param   pVM                 The VM handle.
    4369 * @param   pszGroupSettings    The group settings string. (VBOX_LOG)
     70 *                              By prefixing the string with \"release:\" the
     71 *                              changes will be applied to the release log
     72 *                              instead of the debug log.  The prefix \"debug:\"
     73 *                              is also recognized.
    4474 */
    4575VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings)
     
    6191static DECLCALLBACK(int) dbgfR3LogModifyGroups(PVM pVM, const char *pszGroupSettings)
    6292{
    63     int rc = RTLogGroupSettings(NULL, pszGroupSettings);
     93    PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszGroupSettings);
     94    if (!pLogger)
     95        return VINF_SUCCESS;
     96
     97    int rc = RTLogGroupSettings(pLogger, pszGroupSettings);
    6498    if (RT_SUCCESS(rc))
    6599        rc = VMMR3UpdateLoggers(pVM);
     
    74108 * @param   pVM                 The VM handle.
    75109 * @param   pszFlagSettings     The group settings string. (VBOX_LOG_FLAGS)
     110 *                              By prefixing the string with \"release:\" the
     111 *                              changes will be applied to the release log
     112 *                              instead of the debug log.  The prefix \"debug:\"
     113 *                              is also recognized.
    76114 */
    77115VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings)
     
    93131static DECLCALLBACK(int) dbgfR3LogModifyFlags(PVM pVM, const char *pszFlagSettings)
    94132{
    95     int rc = RTLogFlags(NULL, pszFlagSettings);
     133    PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszFlagSettings);
     134    if (!pLogger)
     135        return VINF_SUCCESS;
     136
     137    int rc = RTLogFlags(pLogger, pszFlagSettings);
    96138    if (RT_SUCCESS(rc))
    97139        rc = VMMR3UpdateLoggers(pVM);
     
    106148 * @param   pVM                 The VM handle.
    107149 * @param   pszDestSettings     The destination settings string. (VBOX_LOG_DEST)
     150 *                              By prefixing the string with \"release:\" the
     151 *                              changes will be applied to the release log
     152 *                              instead of the debug log.  The prefix \"debug:\"
     153 *                              is also recognized.
    108154 */
    109155VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings)
     
    125171static DECLCALLBACK(int) dbgfR3LogModifyDestinations(PVM pVM, const char *pszDestSettings)
    126172{
     173    PRTLOGGER pLogger = dbgfR3LogResolvedLogger(&pszDestSettings);
     174    if (!pLogger)
     175        return VINF_SUCCESS;
     176
    127177    int rc = RTLogDestinations(NULL, pszDestSettings);
    128178    if (RT_SUCCESS(rc))
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