Changeset 39675 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 21, 2011 11:49:52 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDebugVM.cpp
r39668 r39675 404 404 } 405 405 406 /** @name debugvm show flags 407 * @{ */ 408 #define DEBUGVM_SHOW_FLAGS_HUMAN_READABLE UINT32_C(0x00000000) 409 #define DEBUGVM_SHOW_FLAGS_SH_EXPORT UINT32_C(0x00000001) 410 #define DEBUGVM_SHOW_FLAGS_SH_EVAL UINT32_C(0x00000002) 411 #define DEBUGVM_SHOW_FLAGS_CMD_SET UINT32_C(0x00000003) 412 #define DEBUGVM_SHOW_FLAGS_FMT_MASK UINT32_C(0x00000003) 413 /** @} */ 414 415 /** 416 * Prints a variable according to the @a fFlags. 417 * 418 * @param pszVar The variable name. 419 * @param pbstrValue The variable value. 420 * @param fFlags The debugvm show flags. 421 */ 422 static void handleDebugVM_Show_PrintVar(const char *pszVar, com::Bstr const *pbstrValue, uint32_t fFlags) 423 { 424 switch (fFlags & DEBUGVM_SHOW_FLAGS_FMT_MASK) 425 { 426 case DEBUGVM_SHOW_FLAGS_HUMAN_READABLE: RTPrintf(" %27s=%ls\n", pszVar, pbstrValue->raw()); break; 427 case DEBUGVM_SHOW_FLAGS_SH_EXPORT: RTPrintf("export %s='%ls'\n", pszVar, pbstrValue->raw()); break; 428 case DEBUGVM_SHOW_FLAGS_SH_EVAL: RTPrintf("%s='%ls'\n", pszVar, pbstrValue->raw()); break; 429 case DEBUGVM_SHOW_FLAGS_CMD_SET: RTPrintf("set %s=%ls\n", pszVar, pbstrValue->raw()); break; 430 default: AssertFailed(); 431 } 432 } 433 434 /** 435 * Handles logdbg-settings. 436 * 437 * @returns Exit code. 438 * @param pDebugger The debugger interface. 439 * @param fFlags The debugvm show flags. 440 */ 441 static RTEXITCODE handleDebugVM_Show_LogDbgSettings(IMachineDebugger *pDebugger, uint32_t fFlags) 442 { 443 if ((fFlags & DEBUGVM_SHOW_FLAGS_FMT_MASK) == DEBUGVM_SHOW_FLAGS_HUMAN_READABLE) 444 RTPrintf("Debug logger settings:\n"); 445 446 com::Bstr bstr; 447 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgFlags)(bstr.asOutParam()), RTEXITCODE_FAILURE); 448 handleDebugVM_Show_PrintVar("VBOX_LOG", &bstr, fFlags); 449 450 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgGroups)(bstr.asOutParam()), RTEXITCODE_FAILURE); 451 handleDebugVM_Show_PrintVar("VBOX_LOG_FLAGS", &bstr, fFlags); 452 453 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgDestinations)(bstr.asOutParam()), RTEXITCODE_FAILURE); 454 handleDebugVM_Show_PrintVar("VBOX_LOG_DEST", &bstr, fFlags); 455 return RTEXITCODE_SUCCESS; 456 } 457 458 /** 459 * Handles logrel-settings. 460 * 461 * @returns Exit code. 462 * @param pDebugger The debugger interface. 463 * @param fFlags The debugvm show flags. 464 */ 465 static RTEXITCODE handleDebugVM_Show_LogRelSettings(IMachineDebugger *pDebugger, uint32_t fFlags) 466 { 467 if ((fFlags & DEBUGVM_SHOW_FLAGS_FMT_MASK) == DEBUGVM_SHOW_FLAGS_HUMAN_READABLE) 468 RTPrintf("Release logger settings:\n"); 469 470 com::Bstr bstr; 471 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelFlags)(bstr.asOutParam()), RTEXITCODE_FAILURE); 472 handleDebugVM_Show_PrintVar("VBOX_RELEASE_LOG", &bstr, fFlags); 473 474 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelGroups)(bstr.asOutParam()), RTEXITCODE_FAILURE); 475 handleDebugVM_Show_PrintVar("VBOX_RELEASE_LOG_FLAGS", &bstr, fFlags); 476 477 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelDestinations)(bstr.asOutParam()), RTEXITCODE_FAILURE); 478 handleDebugVM_Show_PrintVar("VBOX_RELEASE_LOG_DEST", &bstr, fFlags); 479 return RTEXITCODE_SUCCESS; 480 } 481 406 482 /** 407 483 * Handles the show sub-command. … … 413 489 static RTEXITCODE handleDebugVM_Show(HandlerArg *pArgs, IMachineDebugger *pDebugger) 414 490 { 415 if (pArgs->argc != 3) 416 return errorSyntax(USAGE_DEBUGVM, "The show sub-command takes exactly one argument"); 417 418 const char *pszWhat = pArgs->argv[2]; 419 if ( !strcmp(pszWhat, "log-settings") 420 || !strcmp(pszWhat, "logdbg-settings")) 421 { 422 com::Bstr bstrFlags; 423 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgFlags)(bstrFlags.asOutParam()), RTEXITCODE_FAILURE); 424 com::Bstr bstrGroups; 425 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgGroups)(bstrGroups.asOutParam()), RTEXITCODE_FAILURE); 426 com::Bstr bstrDestinations; 427 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogDbgDestinations)(bstrDestinations.asOutParam()), RTEXITCODE_FAILURE); 428 RTPrintf("Debug log settings:\n"); 429 RTPrintf(" VBOX_LOG=%ls\n" 430 " VBOX_LOG_FLAGS=%ls\n" 431 " VBOX_LOG_DEST=%ls\n" 432 , bstrGroups.raw(), bstrFlags.raw(), bstrDestinations.raw()); 433 } 434 else if (!strcmp(pszWhat, "logrel-settings")) 435 { 436 com::Bstr bstrFlags; 437 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelFlags)(bstrFlags.asOutParam()), RTEXITCODE_FAILURE); 438 com::Bstr bstrGroups; 439 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelGroups)(bstrGroups.asOutParam()), RTEXITCODE_FAILURE); 440 com::Bstr bstrDestinations; 441 CHECK_ERROR2_RET(pDebugger, COMGETTER(LogRelDestinations)(bstrDestinations.asOutParam()), RTEXITCODE_FAILURE); 442 RTPrintf("Release log settings:\n"); 443 RTPrintf(" VBOX_RELEASE_LOG=%ls\n" 444 " VBOX_RELEASE_LOG_FLAGS=%ls\n" 445 " VBOX_RELEASE_LOG_DEST=%ls\n" 446 , bstrGroups.raw(), bstrFlags.raw(), bstrDestinations.raw()); 447 } 448 else 449 return errorSyntax(USAGE_DEBUGVM, "The show sub-command has no idea what '%s' might be", pszWhat); 450 491 /* 492 * Parse arguments and what to show. Order dependent. 493 */ 494 uint32_t fFlags = DEBUGVM_SHOW_FLAGS_HUMAN_READABLE; 495 496 RTGETOPTSTATE GetState; 497 RTGETOPTUNION ValueUnion; 498 static const RTGETOPTDEF s_aOptions[] = 499 { 500 { "--human-readable", 'H', RTGETOPT_REQ_NOTHING }, 501 { "--sh-export", 'e', RTGETOPT_REQ_NOTHING }, 502 { "--sh-eval", 'E', RTGETOPT_REQ_NOTHING }, 503 { "--cmd-set", 's', RTGETOPT_REQ_NOTHING }, 504 }; 505 int rc = RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 2, 0 /*fFlags*/); 506 AssertRCReturn(rc, RTEXITCODE_FAILURE); 507 508 while ((rc = RTGetOpt(&GetState, &ValueUnion)) != 0) 509 { 510 switch (rc) 511 { 512 case 'H': 513 fFlags = (fFlags & ~DEBUGVM_SHOW_FLAGS_FMT_MASK) | DEBUGVM_SHOW_FLAGS_HUMAN_READABLE; 514 break; 515 516 case 'e': 517 fFlags = (fFlags & ~DEBUGVM_SHOW_FLAGS_FMT_MASK) | DEBUGVM_SHOW_FLAGS_SH_EXPORT; 518 break; 519 520 case 'E': 521 fFlags = (fFlags & ~DEBUGVM_SHOW_FLAGS_FMT_MASK) | DEBUGVM_SHOW_FLAGS_SH_EVAL; 522 break; 523 524 case 's': 525 fFlags = (fFlags & ~DEBUGVM_SHOW_FLAGS_FMT_MASK) | DEBUGVM_SHOW_FLAGS_CMD_SET; 526 break; 527 528 case VINF_GETOPT_NOT_OPTION: 529 { 530 RTEXITCODE rcExit; 531 if (!strcmp(ValueUnion.psz, "log-settings")) 532 { 533 rcExit = handleDebugVM_Show_LogDbgSettings(pDebugger, fFlags); 534 if (rcExit == RTEXITCODE_SUCCESS) 535 rcExit = handleDebugVM_Show_LogRelSettings(pDebugger, fFlags); 536 } 537 else if (!strcmp(ValueUnion.psz, "logdbg-settings")) 538 rcExit = handleDebugVM_Show_LogDbgSettings(pDebugger, fFlags); 539 else if (!strcmp(ValueUnion.psz, "logrel-settings")) 540 rcExit = handleDebugVM_Show_LogRelSettings(pDebugger, fFlags); 541 else 542 rcExit = errorSyntax(USAGE_DEBUGVM, "The show sub-command has no idea what '%s' might be", ValueUnion.psz); 543 if (rcExit != RTEXITCODE_SUCCESS) 544 return rcExit; 545 break; 546 } 547 548 default: 549 return errorGetOpt(USAGE_DEBUGVM, rc, &ValueUnion); 550 } 551 } 451 552 return RTEXITCODE_SUCCESS; 452 553 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r39668 r39675 652 652 " getregisters [--cpu <id>] <reg>|all ... |\n" 653 653 " setregisters [--cpu <id>] <reg>=<value> ... |\n" 654 " show <logdbg-settings|logrel-settings> |\n" 654 " show [--human-readable|--sh-export|--sh-eval|--cmd-set] \n" 655 " <logdbg-settings|logrel-settings> [[opt] what ...] |\n" 655 656 " statistics [--reset] [--pattern <pattern>]\n" 656 657 " [--descriptions]\n"
Note:
See TracChangeset
for help on using the changeset viewer.