VirtualBox

Changeset 61937 in vbox


Ignore:
Timestamp:
Jun 29, 2016 4:36:07 PM (8 years ago)
Author:
vboxsync
Message:

Renamed the 'VBoxmanage debugvm dumpgueststack' command to just 'stack' and documented it in the manual. Also, default to dump all stacks (untested).

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-debugvm.xml

    r61673 r61937  
    3939      <arg>--filename=<replaceable>name</replaceable></arg>
    4040    </cmdsynopsis>
    41     <cmdsynopsis id="synopsis-vboxmanage-debugvm-dumpgueststack">
    42       <command>VBoxManage debugvm</command>
    43       <arg choice="req"><replaceable>uuid|vmname</replaceable></arg>
    44       <arg choice="plain">dumpgueststack</arg>
    45       <arg>--cpu=<replaceable>id</replaceable></arg>
    46     </cmdsynopsis>
    4741    <cmdsynopsis id="synopsis-vboxmanage-debugvm-info">
    4842      <command>VBoxManage debugvm</command>
     
    114108      <group><arg>--human-readable</arg><arg>--sh-export</arg><arg>--sh-eval</arg><arg>--cmd-set</arg></group>
    115109      <arg rep="repeat"><replaceable>settings-item</replaceable></arg>
     110    </cmdsynopsis>
     111    <cmdsynopsis id="synopsis-vboxmanage-debugvm-stack">
     112      <command>VBoxManage debugvm</command>
     113      <arg choice="req"><replaceable>uuid|vmname</replaceable></arg>
     114      <arg choice="plain">stack</arg>
     115      <arg>--cpu=<replaceable>id</replaceable></arg>
    116116    </cmdsynopsis>
    117117    <cmdsynopsis id="synopsis-vboxmanage-debugvm-statistics">
     
    569569    </refsect2>
    570570
     571    <refsect2 id="vboxmanage-debugvm-stack">
     572      <title>debugvm stack</title>
     573      <remark role="help-copy-synopsis"/>
     574      <para>
     575        Unwinds the guest CPU stacks to the best of our ability.  For Windows
     576        guest it is recommended to first run the <command>osdetect</command> command.
     577      </para>
     578      <variablelist>
     579        <varlistentry>
     580          <term><option>--cpu <replaceable>id</replaceable></option></term>
     581          <listitem><para>Selects a single guest CPU to display the stack for.  The default is all CPUs.</para> </listitem>
     582        </varlistentry>
     583      </variablelist>
     584
     585    </refsect2>
     586
    571587    <refsect2 id="vboxmanage-debugvm-statistics">
    572588      <title>debugvm statistics</title>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp

    r61673 r61937  
    2828#include <VBox/com/VirtualBox.h>
    2929
     30#include <VBox/types.h>
    3031#include <iprt/ctype.h>
    3132#include <VBox/err.h>
     
    640641
    641642/**
     643 * Handles the stack sub-command.
     644 *
     645 * @returns Suitable exit code.
     646 * @param   pArgs               The handler arguments.
     647 * @param   pDebugger           Pointer to the debugger interface.
     648 */
     649static RTEXITCODE handleDebugVM_Stack(HandlerArg *pArgs, IMachineDebugger *pDebugger)
     650{
     651    /*
     652     * Parse arguments.
     653     */
     654    VMCPUID                     idCpu = VMCPUID_ALL;
     655
     656    RTGETOPTSTATE               GetState;
     657    RTGETOPTUNION               ValueUnion;
     658    static const RTGETOPTDEF    s_aOptions[] =
     659    {
     660        { "--cpu", 'c', RTGETOPT_REQ_UINT32 },
     661    };
     662    int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);
     663    AssertRCReturn(rc, RTEXITCODE_FAILURE);
     664
     665    while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
     666    {
     667        switch (rc)
     668        {
     669            case 'c':
     670                idCpu = ValueUnion.u32;
     671                break;
     672
     673            default:
     674                return errorGetOpt(rc, &ValueUnion);
     675        }
     676    }
     677
     678    /*
     679     * Dump stack.
     680     */
     681    com::Bstr bstrGuestStack;
     682    if (idCpu != VMCPUID_ALL)
     683    {
     684        /* Single CPU */
     685        CHECK_ERROR2I_RET(pDebugger, DumpGuestStack(idCpu, bstrGuestStack.asOutParam()), RTEXITCODE_FAILURE);
     686        RTPrintf("%ls\n", bstrGuestStack.raw());
     687    }
     688    else
     689    {
     690        /* All CPUs. */
     691        ComPtr<IMachine> ptrMachine;
     692        CHECK_ERROR2I_RET(pArgs->session, COMGETTER(Machine)(ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
     693        ULONG cCpus;
     694        CHECK_ERROR2I_RET(ptrMachine, COMGETTER(CPUCount)(&cCpus), RTEXITCODE_FAILURE);
     695
     696        for (idCpu = 0; idCpu < (VMCPUID)cCpus; idCpu++)
     697        {
     698            CHECK_ERROR2I_RET(pDebugger, DumpGuestStack(idCpu, bstrGuestStack.asOutParam()), RTEXITCODE_FAILURE);
     699            if (cCpus > 1)
     700            {
     701                if (idCpu > 0)
     702                    RTPrintf("\n");
     703                RTPrintf("====================== CPU #%u ======================\n", idCpu);
     704            }
     705            RTPrintf("%ls\n", bstrGuestStack.raw());
     706        }
     707    }
     708
     709
     710    return RTEXITCODE_SUCCESS;
     711}
     712
     713/**
    642714 * Handles the statistics sub-command.
    643715 *
     
    713785}
    714786
    715 /**
    716  * Handles the dumpgueststack sub-command.
    717  *
    718  * @returns Suitable exit code.
    719  * @param   pArgs               The handler arguments.
    720  * @param   pDebugger           Pointer to the debugger interface.
    721  */
    722 static RTEXITCODE handleDebugVM_DumpGuestStack(HandlerArg *pArgs, IMachineDebugger *pDebugger)
    723 {
    724     ULONG                       idCpu = 0;
    725 
    726     RTGETOPTSTATE               GetState;
    727     RTGETOPTUNION               ValueUnion;
    728     static const RTGETOPTDEF    s_aOptions[] =
    729     {
    730         { "--cpu", 'c', RTGETOPT_REQ_UINT32 },
    731     };
    732     int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);
    733     AssertRCReturn(rc, RTEXITCODE_FAILURE);
    734 
    735     while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
    736     {
    737         switch (rc)
    738         {
    739             case 'c':
    740                 idCpu = ValueUnion.u32;
    741                 break;
    742 
    743             default:
    744                 return errorGetOpt(rc, &ValueUnion);
    745         }
    746     }
    747 
    748     com::Bstr bstrGuestStack;
    749     CHECK_ERROR2I_RET(pDebugger, DumpGuestStack(idCpu, bstrGuestStack.asOutParam()),
    750                       RTEXITCODE_FAILURE);
    751 
    752     RTPrintf("%ls\n", bstrGuestStack.raw());
    753 
    754     return RTEXITCODE_SUCCESS;
    755 }
    756 
    757787RTEXITCODE handleDebugVM(HandlerArg *pArgs)
    758788{
     
    771801     * Get the associated console and machine debugger.
    772802     */
    773     HRESULT rc;
     803    HRESULT hrc;
    774804    ComPtr<IConsole> ptrConsole;
    775     CHECK_ERROR(pArgs->session, COMGETTER(Console)(ptrConsole.asOutParam()));
    776     if (SUCCEEDED(rc))
     805    CHECK_ERROR2(hrc, pArgs->session, COMGETTER(Console)(ptrConsole.asOutParam()));
     806    if (SUCCEEDED(hrc))
    777807    {
    778808        if (ptrConsole.isNotNull())
    779809        {
    780810            ComPtr<IMachineDebugger> ptrDebugger;
    781             CHECK_ERROR(ptrConsole, COMGETTER(Debugger)(ptrDebugger.asOutParam()));
    782             if (SUCCEEDED(rc))
     811            CHECK_ERROR2(hrc, ptrConsole, COMGETTER(Debugger)(ptrDebugger.asOutParam()));
     812            if (SUCCEEDED(hrc))
    783813            {
    784814                /*
     
    846876                    rcExit = handleDebugVM_Show(pArgs, ptrDebugger);
    847877                }
     878                else if (!strcmp(pszSubCmd, "stack"))
     879                {
     880                    setCurrentSubcommand(HELP_SCOPE_DEBUGVM_STACK);
     881                    rcExit = handleDebugVM_Stack(pArgs, ptrDebugger);
     882                }
    848883                else if (!strcmp(pszSubCmd, "statistics"))
    849884                {
    850885                    setCurrentSubcommand(HELP_SCOPE_DEBUGVM_STATISTICS);
    851886                    rcExit = handleDebugVM_Statistics(pArgs, ptrDebugger);
    852                 }
    853                 else if (!strcmp(pszSubCmd, "dumpgueststack"))
    854                 {
    855                     setCurrentSubcommand(HELP_SCOPE_DEBUGVM_DUMPGUESTSTACK);
    856                     rcExit = handleDebugVM_DumpGuestStack(pArgs, ptrDebugger);
    857887                }
    858888                else
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r61673 r61937  
    12741274#endif /* VBOX_WITH_GUEST_CONTROL defined */
    12751275
    1276     if (fCategory & USAGE_DEBUGVM)
    1277     {
    1278         RTStrmPrintf(pStrm,
    1279                            "%s debugvm %s         <uuid|vmname>\n"
    1280                      "                            dumpvmcore --filename <name> |\n"
    1281                      "                            dumpgueststack [--cpu <id>]\n"
    1282                      "                            info <item> [args] |\n"
    1283                      "                            injectnmi |\n"
    1284                      "                            log [--release|--debug] <settings> ...|\n"
    1285                      "                            logdest [--release|--debug] <settings> ...|\n"
    1286                      "                            logflags [--release|--debug] <settings> ...|\n"
    1287                      "                            osdetect |\n"
    1288                      "                            osinfo |\n"
    1289                      "                            osdmesg [--lines|-n <N>] |\n"
    1290                      "                            getregisters [--cpu <id>] <reg>|all ... |\n"
    1291                      "                            setregisters [--cpu <id>] <reg>=<value> ... |\n"
    1292                      "                            show [--human-readable|--sh-export|--sh-eval|\n"
    1293                      "                                  --cmd-set] \n"
    1294                      "                                <logdbg-settings|logrel-settings>\n"
    1295                      "                                [[opt] what ...] |\n"
    1296                      "                            statistics [--reset] [--pattern <pattern>]\n"
    1297                      "                            [--descriptions]\n"
    1298                      "\n", SEP);
    1299     }
    13001276    if (fCategory & USAGE_METRICS)
    13011277        RTStrmPrintf(pStrm,
     
    14061382        {
    14071383            PCREFENTRY pHelp = g_apHelpEntries[i];
    1408             RTStrmPrintf(pStrm, "  %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
    1409             cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, REFENTRYSTR_SCOPE_GLOBAL, cPendingBlankLines);
    1410             if (!cPendingBlankLines)
    1411                 cPendingBlankLines = 1;
     1384            while (cPendingBlankLines-- > 0)
     1385                RTStrmPutCh(pStrm, '\n');
     1386            RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
     1387            cPendingBlankLines = printStringTable(pStrm, &pHelp->Synopsis, REFENTRYSTR_SCOPE_GLOBAL, 0);
     1388            cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
    14121389        }
    14131390    }
    1414 
    14151391#endif
    14161392}
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