VirtualBox

Changeset 35508 in vbox


Ignore:
Timestamp:
Jan 12, 2011 2:54:12 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69391
Message:

VBoxManage: Added the getregisters and setregisters subcommands to debugvm. Document them and other recent debugvm additions.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/user_VBoxManage.xml

    r35285 r35508  
    13971397    cable on a physical machine, and should be avoided if possible.</para>
    13981398  </sect1>
    1399  
     1399
    14001400  <sect1>
    14011401    <title>VBoxManage adoptstate</title>
    1402    
     1402
    14031403    <para>If you have a saved state file (<computeroutput>.sav</computeroutput>)
    14041404    that is seperate from the VM configuration, you can use this command to
     
    17231723      </glosslist></para>
    17241724  </sect1>
    1725  
     1725
    17261726  <sect1 id="vboxmanage-storagectl">
    17271727    <title>VBoxManage storagectl</title>
     
    27772777          will have the standard ELF core format (with custom sections); see
    27782778          <xref linkend="guestcoreformat" />.</para>
     2779
     2780          <para>This corresponds to the
     2781          <computeroutput>writecore</computeroutput> command in the debugger.
     2782          </para>
     2783        </listitem>
     2784
     2785        <listitem>
     2786          <para>The <computeroutput>info</computeroutput> command is used to
     2787          display info items relating to the VMM, device emulations and
     2788          associated drivers.  This command takes one or two arguments: the
     2789          name of the info item, optionally followed by a string containing
     2790          arguments specific to the info item.
     2791          The <computeroutput>help</computeroutput> info item provides a
     2792          listning of the available items and hints about any optional
     2793          arguments.</para>
     2794
     2795          <para>This corresponds to the <computeroutput>info</computeroutput>
     2796          command in the debugger.</para>
    27792797        </listitem>
    27802798
     
    27862804          operating system. Do not use unless you know what you're
    27872805          doing.</para>
     2806        </listitem>
     2807
     2808        <listitem>
     2809          <para>The <computeroutput>osdetect</computeroutput> command makes the
     2810          VMM's debugger facility (re-)detection the guest operation
     2811          system.</para>
     2812
     2813          <para>This corresponds to the <computeroutput>detect</computeroutput>
     2814          command in the debugger.</para>
     2815        </listitem>
     2816
     2817        <listitem>
     2818          <para>The <computeroutput>osinfo</computeroutput> command is used to
     2819          display info about the operating system (OS) detected by the VMM's
     2820          debugger facility.</para>
     2821        </listitem>
     2822
     2823        <listitem>
     2824          <para>The <computeroutput>getregisters</computeroutput> command is
     2825          used to display CPU and device registers.  The command takes a list
     2826          of registers, each having one of the following forms:
     2827          <itemizedlist>
     2828            <listitem><computeroutput>register-set.register-name.sub-field</computeroutput></listitem>
     2829            <listitem><computeroutput>register-set.register-name</computeroutput></listitem>
     2830            <listitem><computeroutput>cpu-register-name.sub-field</computeroutput></listitem>
     2831            <listitem><computeroutput>cpu-register-name</computeroutput></listitem>
     2832            <listitem><computeroutput>all</computeroutput></listitem>
     2833          </itemizedlist>
     2834          The <computeroutput>all</computeroutput> form will cause all
     2835          registers to be shown (no sub-fields).  The registers names are
     2836          case-insensitive.  When requesting a CPU register the register set
     2837          can be omitted, it will be selected using the value of the
     2838          <computeroutput>--cpu</computeroutput> option (defaulting to 0).
     2839          </para>
     2840        </listitem>
     2841
     2842        <listitem>
     2843          <para>The <computeroutput>setregisters</computeroutput> command is
     2844          used to change CPU and device registers.  The command takes a list
     2845          of register assignments, each having one of the following forms:
     2846          <itemizedlist>
     2847            <listitem><computeroutput>register-set.register-name.sub-field=value</computeroutput></listitem>
     2848            <listitem><computeroutput>register-set.register-name=value</computeroutput></listitem>
     2849            <listitem><computeroutput>cpu-register-name.sub-field=value</computeroutput></listitem>
     2850            <listitem><computeroutput>cpu-register-name=value</computeroutput></listitem>
     2851          </itemizedlist>
     2852          The value format should be in the same style as what
     2853          <computeroutput>getregisters</computeroutput> displays, with the
     2854          exception that both octal and decimal can be used instead of
     2855          hexadecimal.  The register naming and the default CPU register set
     2856          are handled the same way as with the
     2857          <computeroutput>getregisters</computeroutput> command.</para>
    27882858        </listitem>
    27892859
     
    27992869      </itemizedlist></para>
    28002870  </sect1>
    2801  
     2871
    28022872  <sect1>
    28032873    <title id="metrics">VBoxManage metrics</title>
     
    29543024    </glosslist>
    29553025  </sect1>
    2956  
     3026
    29573027  <sect1>
    29583028    <title>VBoxManage hostonlyif</title>
    2959    
     3029
    29603030    <para>With "hostonlyif" you can change the IP configuration of a host-only
    29613031    network interface. For a description of host-only networking, please
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp

    r35351 r35508  
    4444
    4545/**
     46 * Handles the getregisters sub-command.
     47 *
     48 * @returns Suitable exit code.
     49 * @param   pArgs               The handler arguments.
     50 * @param   pDebugger           Pointer to the debugger interface.
     51 */
     52static RTEXITCODE handleDebugVM_GetRegisters(HandlerArg *pArgs, IMachineDebugger *pDebugger)
     53{
     54    /*
     55     * We take a list of register names (case insensitive).  If 'all' is
     56     * encountered we'll dump all registers.
     57     */
     58    ULONG                       idCpu = 0;
     59    unsigned                    cRegisters = 0;
     60
     61    RTGETOPTSTATE               GetState;
     62    RTGETOPTUNION               ValueUnion;
     63    static const RTGETOPTDEF    s_aOptions[] =
     64    {
     65        { "--cpu", 'c', RTGETOPT_REQ_UINT32 },
     66    };
     67    int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);
     68    AssertRCReturn(rc, RTEXITCODE_FAILURE);
     69
     70    while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
     71    {
     72        switch (rc)
     73        {
     74            case 'c':
     75                idCpu = ValueUnion.u32;
     76                break;
     77
     78            case VINF_GETOPT_NOT_OPTION:
     79                if (!RTStrICmp(ValueUnion.psz, "all"))
     80                {
     81                    com::SafeArray<BSTR> aBstrNames;
     82                    com::SafeArray<BSTR> aBstrValues;
     83                    CHECK_ERROR2_RET(pDebugger, GetRegisters(idCpu, ComSafeArrayAsOutParam(aBstrNames), ComSafeArrayAsOutParam(aBstrValues)),
     84                                     RTEXITCODE_FAILURE);
     85                    Assert(aBstrNames.size() == aBstrValues.size());
     86
     87                    for (size_t i = 0; i < aBstrNames.size(); i++)
     88                        RTPrintf("%ls = %ls\n", aBstrNames[i], aBstrValues[i]);
     89                }
     90                else
     91                {
     92                    com::Bstr bstrName = ValueUnion.psz;
     93                    com::Bstr bstrValue;
     94                    CHECK_ERROR2_RET(pDebugger, GetRegister(idCpu, bstrName.raw(), bstrValue.asOutParam()), RTEXITCODE_FAILURE);
     95                    RTPrintf("%s = %ls\n", ValueUnion.psz, bstrValue.raw());
     96                }
     97                cRegisters++;
     98                break;
     99
     100            default:
     101                return errorGetOpt(USAGE_DEBUGVM, rc, &ValueUnion);
     102        }
     103    }
     104
     105    if (!cRegisters)
     106        return errorSyntax(USAGE_DEBUGVM, "The getregisters sub-command takes at least one register name");
     107    return RTEXITCODE_SUCCESS;
     108}
     109
     110/**
    46111 * Handles the info sub-command.
    47112 *
     
    175240    RTPrintf("Name:    %ls\n", bstrName.raw());
    176241    RTPrintf("Version: %ls\n", bstrVersion.raw());
     242    return RTEXITCODE_SUCCESS;
     243}
     244
     245/**
     246 * Handles the setregisters sub-command.
     247 *
     248 * @returns Suitable exit code.
     249 * @param   pArgs               The handler arguments.
     250 * @param   pDebugger           Pointer to the debugger interface.
     251 */
     252static RTEXITCODE handleDebugVM_SetRegisters(HandlerArg *pArgs, IMachineDebugger *pDebugger)
     253{
     254    /*
     255     * We take a list of register assignments, that is register=value.
     256     */
     257    ULONG                       idCpu = 0;
     258    com::SafeArray<IN_BSTR>     aBstrNames;
     259    com::SafeArray<IN_BSTR>     aBstrValues;
     260
     261    RTGETOPTSTATE               GetState;
     262    RTGETOPTUNION               ValueUnion;
     263    static const RTGETOPTDEF    s_aOptions[] =
     264    {
     265        { "--cpu", 'c', RTGETOPT_REQ_UINT32 },
     266    };
     267    int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, RTGETOPTINIT_FLAGS_OPTS_FIRST);
     268    AssertRCReturn(rc, RTEXITCODE_FAILURE);
     269
     270    while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0)
     271    {
     272        switch (rc)
     273        {
     274            case 'c':
     275                idCpu = ValueUnion.u32;
     276                break;
     277
     278            case VINF_GETOPT_NOT_OPTION:
     279            {
     280                const char *pszEqual = strchr(ValueUnion.psz, '=');
     281                if (!pszEqual)
     282                    return errorSyntax(USAGE_DEBUGVM, "setregisters expects input on the form 'register=value' got '%s'", ValueUnion.psz);
     283                try
     284                {
     285                    com::Bstr bstrName(ValueUnion.psz, pszEqual - ValueUnion.psz);
     286                    com::Bstr bstrValue(pszEqual + 1);
     287                    if (   !aBstrNames.push_back(bstrName.raw())
     288                        || !aBstrValues.push_back(bstrValue.raw()))
     289                        throw std::bad_alloc();
     290                }
     291                catch (std::bad_alloc)
     292                {
     293                    RTMsgError("Out of memory\n");
     294                    return RTEXITCODE_FAILURE;
     295                }
     296                break;
     297            }
     298
     299            default:
     300                return errorGetOpt(USAGE_DEBUGVM, rc, &ValueUnion);
     301        }
     302    }
     303
     304    if (!aBstrNames.size())
     305        return errorSyntax(USAGE_DEBUGVM, "The setregisters sub-command takes at least one register name");
     306
     307    /*
     308     * If it is only one register, use the single register method just so
     309     * we expose it and can test it from the command line.
     310     */
     311    if (aBstrNames.size() == 1)
     312    {
     313        CHECK_ERROR2_RET(pDebugger, SetRegister(idCpu, aBstrNames[0], aBstrValues[0]), RTEXITCODE_FAILURE);
     314        RTPrintf("Successfully set %ls\n", aBstrNames[0]);
     315    }
     316    else
     317    {
     318        CHECK_ERROR2_RET(pDebugger, SetRegisters(idCpu, ComSafeArrayAsInParam(aBstrNames), ComSafeArrayAsInParam(aBstrValues)), RTEXITCODE_FAILURE);
     319        RTPrintf("Successfully set %u registers\n", aBstrNames.size());
     320    }
     321
    177322    return RTEXITCODE_SUCCESS;
    178323}
     
    283428            if (!strcmp(pszSubCmd, "dumpguestcore"))
    284429                rcExit = handleDebugVM_DumpVMCore(pArgs, ptrDebugger);
     430            else if (!strcmp(pszSubCmd, "getregisters"))
     431                rcExit = handleDebugVM_GetRegisters(pArgs, ptrDebugger);
    285432            else if (!strcmp(pszSubCmd, "info"))
    286433                rcExit = handleDebugVM_Info(pArgs, ptrDebugger);
     
    291438            else if (!strcmp(pszSubCmd, "osinfo"))
    292439                rcExit = handleDebugVM_OSInfo(pArgs, ptrDebugger);
     440            else if (!strcmp(pszSubCmd, "setregisters"))
     441                rcExit = handleDebugVM_SetRegisters(pArgs, ptrDebugger);
    293442            else if (!strcmp(pszSubCmd, "statistics"))
    294443                rcExit = handleDebugVM_Statistics(pArgs, ptrDebugger);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r35317 r35508  
    616616                     "                            osdetect |\n"
    617617                     "                            osinfo |\n"
     618                     "                            getregisters [--cpu <id>] <reg>|all ... |\n"
     619                     "                            setregisters [--cpu <id>] <reg>=<value> ... |\n"
    618620                     "                            statistics [--reset] [--pattern <pattern>]\n"
    619621                     "                            [--descriptions]\n"
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