Changeset 35508 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 12, 2011 2:54:12 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69391
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp
r35351 r35508 44 44 45 45 /** 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 */ 52 static 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 /** 46 111 * Handles the info sub-command. 47 112 * … … 175 240 RTPrintf("Name: %ls\n", bstrName.raw()); 176 241 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 */ 252 static 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 177 322 return RTEXITCODE_SUCCESS; 178 323 } … … 283 428 if (!strcmp(pszSubCmd, "dumpguestcore")) 284 429 rcExit = handleDebugVM_DumpVMCore(pArgs, ptrDebugger); 430 else if (!strcmp(pszSubCmd, "getregisters")) 431 rcExit = handleDebugVM_GetRegisters(pArgs, ptrDebugger); 285 432 else if (!strcmp(pszSubCmd, "info")) 286 433 rcExit = handleDebugVM_Info(pArgs, ptrDebugger); … … 291 438 else if (!strcmp(pszSubCmd, "osinfo")) 292 439 rcExit = handleDebugVM_OSInfo(pArgs, ptrDebugger); 440 else if (!strcmp(pszSubCmd, "setregisters")) 441 rcExit = handleDebugVM_SetRegisters(pArgs, ptrDebugger); 293 442 else if (!strcmp(pszSubCmd, "statistics")) 294 443 rcExit = handleDebugVM_Statistics(pArgs, ptrDebugger); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r35317 r35508 616 616 " osdetect |\n" 617 617 " osinfo |\n" 618 " getregisters [--cpu <id>] <reg>|all ... |\n" 619 " setregisters [--cpu <id>] <reg>=<value> ... |\n" 618 620 " statistics [--reset] [--pattern <pattern>]\n" 619 621 " [--descriptions]\n"
Note:
See TracChangeset
for help on using the changeset viewer.