Changeset 41585 in vbox
- Timestamp:
- Jun 5, 2012 8:38:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCommands.cpp
r41583 r41585 442 442 443 443 /* Can we do it the simple + fast way? */ 444 if ( cchName <= cchCol1445 && (cchSyntax <= cchCol2446 || cchSyntax + cchDesc <= cchCol2 + cchCol3))444 if ( cchName <= cchCol1 445 && cchSyntax <= cchCol2 446 && cchDesc <= cchCol3) 447 447 return DBGCCmdHlpPrintf(pCmdHlp, 448 448 !fExternal ? "%-*s %-*s %s\n" : ".%-*s %-*s %s\n", … … 455 455 DBGCCmdHlpPrintf(pCmdHlp, !fExternal ? "%s" : ".%s", pszName); 456 456 off += cchName; 457 if (off < cchCol1) 458 DBGCCmdHlpPrintf(pCmdHlp, "%*s", cchCol1 - off, ""); 457 ssize_t cchPadding = cchCol1 - off; 458 if (cchPadding <= 0) 459 cchPadding = 0; 459 460 460 461 /* Column 2. */ 461 DBGCCmdHlpPrintf(pCmdHlp, " %s", pszSyntax); 462 off += 1 + cchSyntax; 463 if (off < cchCol1 + 1 + cchCol2) 464 DBGCCmdHlpPrintf(pCmdHlp, "%*s", cchCol1 + 1 + cchCol2 - off, ""); 462 DBGCCmdHlpPrintf(pCmdHlp, "%*s %s", cchPadding, "", pszSyntax); 463 off += cchPadding + 1 + cchSyntax; 464 cchPadding = cchCol1 + 1 + cchCol2 - off; 465 if (cchPadding <= 0) 466 cchPadding = 0; 467 off += cchPadding; 465 468 466 469 /* Column 3. */ 467 470 for (;;) 468 471 { 469 if (off + 1 + cchDesc < cchMaxWidth) 470 return DBGCCmdHlpPrintf(pCmdHlp, " %s\n", pszDescription); 471 472 /** @todo fix this code! */ 473 /* Split on preceeding blank. */ 474 const char *pszNext = &pszDescription[cchCol3]; 475 const char *pszEnd = pszNext; 476 if (!RT_C_IS_BLANK(*pszEnd)) 477 while (pszEnd != pszDescription && !RT_C_IS_BLANK(pszEnd[-1])) 472 ssize_t cchCurWidth = cchMaxWidth - off - 1; 473 if (cchCurWidth != (ssize_t)cchCol3) 474 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 475 else if (cchDesc <= cchCurWidth) 476 return DBGCCmdHlpPrintf(pCmdHlp, "%*s %s\n", cchPadding, "", pszDescription); 477 else 478 { 479 /* Split on preceeding blank. */ 480 const char *pszEnd = &pszDescription[cchCurWidth]; 481 if (!RT_C_IS_BLANK(*pszEnd)) 482 while (pszEnd != pszDescription && !RT_C_IS_BLANK(pszEnd[-1])) 483 pszEnd--; 484 const char *pszNext = pszEnd; 485 486 while (pszEnd != pszDescription && RT_C_IS_BLANK(pszEnd[-1])) 478 487 pszEnd--; 479 while (pszEnd != pszDescription && RT_C_IS_BLANK(pszEnd[-1])) 480 pszEnd--; 481 if (pszEnd == pszDescription) 482 { 483 while (*pszEnd && !RT_C_IS_BLANK(*pszEnd)) 484 pszEnd++; 485 pszNext = pszEnd; 488 if (pszEnd == pszDescription) 489 { 490 while (*pszEnd && !RT_C_IS_BLANK(*pszEnd)) 491 pszEnd++; 492 pszNext = pszEnd; 493 } 494 495 while (RT_C_IS_BLANK(*pszNext)) 496 pszNext++; 497 498 /* Output it and advance to the next line. */ 499 if (!*pszNext) 500 return DBGCCmdHlpPrintf(pCmdHlp, "%*s %.*s\n", cchPadding, "", pszEnd - pszDescription, pszDescription); 501 DBGCCmdHlpPrintf(pCmdHlp, "%*s %.*s\n", cchPadding, "", pszEnd - pszDescription, pszDescription); 502 503 /* next */ 504 cchDesc -= pszNext - pszDescription; 505 pszDescription = pszNext; 486 506 } 487 488 while (RT_C_IS_BLANK(*pszNext))489 pszNext++;490 491 /* Output it and advance to the next line. */492 if (!*pszNext)493 return DBGCCmdHlpPrintf(pCmdHlp, " %.*s\n", pszEnd - pszDescription, pszDescription);494 507 off = cchCol1 + 1 + cchCol2; 495 DBGCCmdHlpPrintf(pCmdHlp, " %.*s\n%*s", pszEnd - pszDescription, pszDescription, off, ""); 496 497 /* next */ 498 cchDesc -= pszNext - pszDescription; 499 pszDescription = pszNext; 508 cchPadding = off; 500 509 } 501 510 } … … 505 514 * Prints full command help. 506 515 */ 507 static int dbgcPrintHelpCmd(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, bool fExternal) 508 { 509 int rc; 516 static void dbgcCmdHelpCmdOrFuncFull(PDBGCCMDHLP pCmdHlp, const char *pszName, bool fExternal, 517 const char *pszSyntax, const char *pszDescription, 518 uint32_t cArgsMin, uint32_t cArgsMax, 519 PCDBGCVARDESC paArgDescs, uint32_t cArgDescs, uint32_t *pcHits) 520 { 521 if (*pcHits) 522 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 523 *pcHits += 1; 510 524 511 525 /* the command */ 512 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 513 "%s%-*s %-30s %s", 514 fExternal ? "." : "", 515 fExternal ? 10 : 11, 516 pCmd->pszCmd, 517 pCmd->pszSyntax, 518 pCmd->pszDescription); 519 if (!pCmd->cArgsMin && pCmd->cArgsMin == pCmd->cArgsMax) 520 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <no args>\n"); 521 else if (pCmd->cArgsMin == pCmd->cArgsMax) 522 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u args>\n", pCmd->cArgsMin); 523 else if (pCmd->cArgsMax == ~0U) 524 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u+ args>\n", pCmd->cArgsMin); 526 dbgcCmdHelpCmdOrFunc(pCmdHlp, pszName, fExternal, pszSyntax, pszDescription); 527 #if 1 528 char szTmp[80]; 529 if (!cArgsMin && cArgsMin == cArgsMax) 530 RTStrPrintf(szTmp, sizeof(szTmp), "<no args>"); 531 else if (cArgsMin == cArgsMax) 532 RTStrPrintf(szTmp, sizeof(szTmp), " <%u args>", cArgsMin); 533 else if (cArgsMax == ~0U) 534 RTStrPrintf(szTmp, sizeof(szTmp), " <%u+ args>", cArgsMin); 525 535 else 526 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u to %u args>\n", pCmd->cArgsMin, pCmd->cArgsMax); 536 RTStrPrintf(szTmp, sizeof(szTmp), " <%u to %u args>", cArgsMin, cArgsMax); 537 dbgcCmdHelpCmdOrFunc(pCmdHlp, "", false, szTmp, ""); 538 #endif 527 539 528 540 /* argument descriptions. */ 529 for (unsigned i = 0; i < pCmd->cArgDescs; i++) 530 { 531 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 532 " %-12s %s", 533 pCmd->paArgDescs[i].pszName, 534 pCmd->paArgDescs[i].pszDescription); 535 if (!pCmd->paArgDescs[i].cTimesMin) 536 { 537 if (pCmd->paArgDescs[i].cTimesMax == ~0U) 538 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <optional+>\n"); 541 for (uint32_t i = 0; i < cArgDescs; i++) 542 { 543 DBGCCmdHlpPrintf(pCmdHlp, " %-12s %s", paArgDescs[i].pszName, paArgDescs[i].pszDescription); 544 if (!paArgDescs[i].cTimesMin) 545 { 546 if (paArgDescs[i].cTimesMax == ~0U) 547 DBGCCmdHlpPrintf(pCmdHlp, " <optional+>\n"); 539 548 else 540 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <optional-%u>\n", pCmd->paArgDescs[i].cTimesMax);549 DBGCCmdHlpPrintf(pCmdHlp, " <optional-%u>\n", paArgDescs[i].cTimesMax); 541 550 } 542 551 else 543 552 { 544 if (p Cmd->paArgDescs[i].cTimesMax == ~0U)545 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u+>\n", pCmd->paArgDescs[i].cTimesMin);553 if (paArgDescs[i].cTimesMax == ~0U) 554 DBGCCmdHlpPrintf(pCmdHlp, " <%u+>\n", paArgDescs[i].cTimesMin); 546 555 else 547 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u-%u>\n", pCmd->paArgDescs[i].cTimesMin, pCmd->paArgDescs[i].cTimesMax);556 DBGCCmdHlpPrintf(pCmdHlp, " <%u-%u>\n", paArgDescs[i].cTimesMin, paArgDescs[i].cTimesMax); 548 557 } 549 558 } 550 return rc; 551 } 552 553 554 static int dbgcCmdHelpCommandsWorker(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, PCDBGCCMD paCmds, size_t cCmds, bool fExternal, 555 const char *pszDescFmt, ...) 556 { 557 int rc = VINF_SUCCESS; 558 559 } 560 561 562 563 /** 564 * Prints full command help. 565 */ 566 static void dbgcPrintHelpCmd(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, bool fExternal, uint32_t *pcHits) 567 { 568 dbgcCmdHelpCmdOrFuncFull(pCmdHlp, pCmd->pszCmd, fExternal, pCmd->pszSyntax, pCmd->pszDescription, 569 pCmd->cArgsMin, pCmd->cArgsMax, pCmd->paArgDescs, pCmd->cArgDescs, pcHits); 570 } 571 572 573 /** 574 * Prints full function help. 575 */ 576 static void dbgcPrintHelpFunction(PDBGCCMDHLP pCmdHlp, PCDBGCFUNC pFunc, bool fExternal, uint32_t *pcHits) 577 { 578 dbgcCmdHelpCmdOrFuncFull(pCmdHlp, pFunc->pszFuncNm, fExternal, pFunc->pszSyntax, pFunc->pszDescription, 579 pFunc->cArgsMin, pFunc->cArgsMax, pFunc->paArgDescs, pFunc->cArgDescs, pcHits); 580 } 581 582 583 static void dbgcCmdHelpCommandsWorker(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, PCDBGCCMD paCmds, uint32_t cCmds, bool fExternal, 584 const char *pszDescFmt, ...) 585 { 559 586 if (pszDescFmt) 560 587 { 561 588 va_list va; 562 589 va_start(va, pszDescFmt); 563 rc =pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszDescFmt, va);590 pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszDescFmt, va); 564 591 va_end(va); 565 592 } 566 593 567 for (unsigned i = 0; i < cCmds && RT_SUCCESS(rc); i++) 568 rc = dbgcCmdHelpCmdOrFunc(pCmdHlp, paCmds[i].pszCmd, fExternal, paCmds[i].pszSyntax, paCmds[i].pszDescription); 569 570 return rc; 571 } 572 573 574 static int dbgcCmdHelpCommands(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp) 575 { 576 int rc = dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, pDbgc->paEmulationCmds, pDbgc->cEmulationCmds, false, 577 "Commands for %s emulation:\n", pDbgc->pszEmulation); 578 if (RT_SUCCESS(rc)) 579 rc = dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, g_aDbgcCmds, RT_ELEMENTS(g_aDbgcCmds), false, 580 "\nCommon Commands:\n"); 581 582 if (RT_SUCCESS(rc)) 583 { 584 DBGCEXTLISTS_LOCK_RD(); 585 const char *pszDesc = "\nExternal Commands:\n"; 586 for (PDBGCEXTCMDS pExtCmd = g_pExtCmdsHead; pExtCmd && RT_SUCCESS(rc); pExtCmd = pExtCmd->pNext) 587 { 588 rc = dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, pExtCmd->paCmds, pExtCmd->cCmds, false, 589 pszDesc); 590 pszDesc = NULL; 591 } 592 DBGCEXTLISTS_UNLOCK_RD(); 593 } 594 595 return rc; 596 } 597 598 599 /** 600 * Prints full function help. 601 */ 602 static int dbgcPrintHelpFunction(PDBGCCMDHLP pCmdHlp, PCDBGCFUNC pFunc, bool fExternal) 603 { 604 int rc; 605 606 /* the command */ 607 rc = DBGCCmdHlpPrintf(pCmdHlp, "%s%-*s %-30s %s", 608 fExternal ? "." : "", 609 fExternal ? 10 : 11, 610 pFunc->pszFuncNm, 611 pFunc->pszSyntax, 612 pFunc->pszDescription); 613 if (!pFunc->cArgsMin && pFunc->cArgsMin == pFunc->cArgsMax) 614 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <no args>\n"); 615 else if (pFunc->cArgsMin == pFunc->cArgsMax) 616 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u args>\n", pFunc->cArgsMin); 617 else if (pFunc->cArgsMax == ~0U) 618 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u+ args>\n", pFunc->cArgsMin); 619 else 620 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u to %u args>\n", pFunc->cArgsMin, pFunc->cArgsMax); 621 622 /* argument descriptions. */ 623 for (unsigned i = 0; i < pFunc->cArgDescs; i++) 624 { 625 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 626 " %-12s %s", 627 pFunc->paArgDescs[i].pszName, 628 pFunc->paArgDescs[i].pszDescription); 629 if (!pFunc->paArgDescs[i].cTimesMin) 630 { 631 if (pFunc->paArgDescs[i].cTimesMax == ~0U) 632 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <optional+>\n"); 633 else 634 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <optional-%u>\n", pFunc->paArgDescs[i].cTimesMax); 635 } 636 else 637 { 638 if (pFunc->paArgDescs[i].cTimesMax == ~0U) 639 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u+>\n", pFunc->paArgDescs[i].cTimesMin); 640 else 641 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, " <%u-%u>\n", pFunc->paArgDescs[i].cTimesMin, 642 pFunc->paArgDescs[i].cTimesMax); 643 } 644 } 645 return rc; 646 } 647 648 649 static int dbgcCmdHelpFunctionsWorker(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, PCDBGCFUNC paFuncs, size_t cFuncs, bool fExternal, 650 const char *pszDescFmt, ...) 651 { 652 int rc = VINF_SUCCESS; 594 for (uint32_t i = 0; i < cCmds; i++) 595 dbgcCmdHelpCmdOrFunc(pCmdHlp, paCmds[i].pszCmd, fExternal, paCmds[i].pszSyntax, paCmds[i].pszDescription); 596 } 597 598 599 static void dbgcCmdHelpCommands(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHits) 600 { 601 if (*pcHits) 602 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 603 *pcHits += 1; 604 605 dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, pDbgc->paEmulationCmds, pDbgc->cEmulationCmds, false, 606 "Commands for %s emulation:\n", pDbgc->pszEmulation); 607 dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, g_aDbgcCmds, RT_ELEMENTS(g_aDbgcCmds), false, 608 "\nCommon Commands:\n"); 609 610 DBGCEXTLISTS_LOCK_RD(); 611 const char *pszDesc = "\nExternal Commands:\n"; 612 for (PDBGCEXTCMDS pExtCmd = g_pExtCmdsHead; pExtCmd; pExtCmd = pExtCmd->pNext) 613 { 614 dbgcCmdHelpCommandsWorker(pDbgc, pCmdHlp, pExtCmd->paCmds, pExtCmd->cCmds, false, pszDesc); 615 pszDesc = NULL; 616 } 617 DBGCEXTLISTS_UNLOCK_RD(); 618 } 619 620 621 static void dbgcCmdHelpFunctionsWorker(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, PCDBGCFUNC paFuncs, size_t cFuncs, bool fExternal, 622 const char *pszDescFmt, ...) 623 { 653 624 if (pszDescFmt) 654 625 { 655 626 va_list va; 656 627 va_start(va, pszDescFmt); 657 rc =DBGCCmdHlpPrintf(pCmdHlp, pszDescFmt, va);628 DBGCCmdHlpPrintf(pCmdHlp, pszDescFmt, va); 658 629 va_end(va); 659 630 } 660 631 661 for (unsigned i = 0; i < cFuncs && RT_SUCCESS(rc); i++) 662 rc = dbgcCmdHelpCmdOrFunc(pCmdHlp, paFuncs[i].pszFuncNm, fExternal, paFuncs[i].pszSyntax, paFuncs[i].pszDescription); 663 return VINF_SUCCESS; 664 } 665 666 667 static int dbgcCmdHelpFunctions(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp) 668 { 669 int rc = dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, pDbgc->paEmulationFuncs, pDbgc->cEmulationFuncs, false, 670 "Functions for %s emulation:\n", pDbgc->pszEmulation); 671 if (RT_SUCCESS(rc)) 672 rc = dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, g_aDbgcFuncs, g_cDbgcFuncs, false, 673 "\nCommon Functions:\n"); 632 for (uint32_t i = 0; i < cFuncs; i++) 633 dbgcCmdHelpCmdOrFunc(pCmdHlp, paFuncs[i].pszFuncNm, fExternal, paFuncs[i].pszSyntax, paFuncs[i].pszDescription); 634 } 635 636 637 static void dbgcCmdHelpFunctions(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHits) 638 { 639 if (*pcHits) 640 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 641 *pcHits += 1; 642 643 dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, pDbgc->paEmulationFuncs, pDbgc->cEmulationFuncs, false, 644 "Functions for %s emulation:\n", pDbgc->pszEmulation); 645 dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, g_aDbgcFuncs, g_cDbgcFuncs, false, 646 "\nCommon Functions:\n"); 674 647 #if 0 675 if (RT_SUCCESS(rc)) 676 { 677 DBGCEXTLISTS_LOCK_RD(); 678 const char *pszDesc = "\nExternal Functions:\n"; 679 for (PDBGCEXTFUNCS pExtFunc = g_pExtFuncsHead; pExtFunc && RT_SUCCESS(rc); pExtFunc = pExtFunc->pNext) 680 { 681 rc = dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, pExtFunc->paFuncs, pExtFunc->cFuncs, false, 682 pszDesc); 683 pszDesc = NULL; 684 } 685 DBGCEXTLISTS_UNLOCK_RD(); 686 } 648 DBGCEXTLISTS_LOCK_RD(); 649 const char *pszDesc = "\nExternal Functions:\n"; 650 for (PDBGCEXTFUNCS pExtFunc = g_pExtFuncsHead; pExtFunc; pExtFunc = pExtFunc->pNext) 651 { 652 dbgcCmdHelpFunctionsWorker(pDbgc, pCmdHlp, pExtFunc->paFuncs, pExtFunc->cFuncs, false, 653 pszDesc); 654 pszDesc = NULL; 655 } 656 DBGCEXTLISTS_UNLOCK_RD(); 687 657 #endif 688 return rc; 689 } 690 691 692 static int dbgcCmdHelpOperators(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp) 693 { 694 int rc = DBGCCmdHlpPrintf(pCmdHlp, "Operators:\n");658 } 659 660 661 static void dbgcCmdHelpOperators(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHits) 662 { 663 DBGCCmdHlpPrintf(pCmdHlp, !*pcHits ? "Operators:\n" : "\nOperators:\n"); 664 *pcHits += 1; 695 665 696 666 unsigned iPrecedence = 0; 697 unsigned cLeft = g_cDbgcOps;667 unsigned cLeft = g_cDbgcOps; 698 668 while (cLeft > 0) 699 669 { … … 701 671 if (g_aDbgcOps[i].iPrecedence == iPrecedence) 702 672 { 703 rc = DBGCCmdHlpPrintf(pCmdHlp, 704 "%-10s %s %s\n", 705 g_aDbgcOps[i].szName, 706 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ", 707 g_aDbgcOps[i].pszDescription); 673 dbgcCmdHelpCmdOrFunc(pCmdHlp, g_aDbgcOps[i].szName, false, 674 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ", 675 g_aDbgcOps[i].pszDescription); 708 676 cLeft--; 709 677 } 710 678 iPrecedence++; 711 679 } 712 return rc; 680 } 681 682 683 static void dbgcCmdHelpAll(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHits) 684 { 685 *pcHits += 1; 686 DBGCCmdHlpPrintf(pCmdHlp, 687 "\n" 688 "VirtualBox Debugger Help\n" 689 "------------------------\n" 690 "\n"); 691 dbgcCmdHelpCommands(pDbgc, pCmdHlp, pcHits); 692 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 693 dbgcCmdHelpFunctions(pDbgc, pCmdHlp, pcHits); 694 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 695 dbgcCmdHelpOperators(pDbgc, pCmdHlp, pcHits); 696 } 697 698 699 static void dbgcCmdHelpSummary(PDBGC pDbgc, PDBGCCMDHLP pCmdHlp, uint32_t *pcHits) 700 { 701 *pcHits += 1; 702 DBGCCmdHlpPrintf(pCmdHlp, 703 "\n" 704 "VirtualBox Debugger Help Summary\n" 705 "--------------------------------\n" 706 "\n" 707 "help commands Show help on all commands.\n" 708 "help functions Show help on all functions.\n" 709 "help operators Show help on all operators.\n" 710 "help all All the above.\n" 711 "help <cmd-pattern> [...]\n" 712 " Show details help on individual commands, simple\n" 713 " patterns can be used to match several commands.\n" 714 "help [summary] Displays this message.\n" 715 ); 713 716 } 714 717 … … 727 730 { 728 731 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 729 int rc = VINF_SUCCESS; 732 int rc = VINF_SUCCESS; 733 uint32_t cHits = 0; 730 734 731 735 if (!cArgs) 732 {733 736 /* 734 737 * No arguments, show summary. 735 738 */ 736 rc = DBGCCmdHlpPrintf(pCmdHlp, 737 "VirtualBox Debugger Help Summary\n" 738 "--------------------------------\n" 739 "\n" 740 "help commands Show help on all commands.\n" 741 "help functions Show help on all functions.\n" 742 "help operators Show help on all operators.\n" 743 "help all All the above.\n" 744 "help <cmd-pattern> [...]\n" 745 " Show details help on individual commands, simple\n" 746 " patterns can be used to match several commands.\n" 747 ); 748 749 } 739 dbgcCmdHelpSummary(pDbgc, pCmdHlp, &cHits); 750 740 else 751 741 { … … 764 754 }; 765 755 766 for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++)756 for (unsigned iArg = 0; iArg < cArgs; iArg++) 767 757 { 768 758 AssertReturn(paArgs[iArg].enmType == DBGCVAR_TYPE_STRING, VERR_DBGC_PARSE_BUG); … … 770 760 771 761 /* aliases */ 772 if (!strcmp(pszPattern, "commands")) 773 rc = dbgcCmdHelpCommands(pDbgc, pCmdHlp); 774 else if (!strcmp(pszPattern, "functions")) 775 rc = dbgcCmdHelpFunctions(pDbgc, pCmdHlp); 776 else if (!strcmp(pszPattern, "operators")) 777 rc = dbgcCmdHelpOperators(pDbgc, pCmdHlp); 762 if ( !strcmp(pszPattern, "commands") 763 || !strcmp(pszPattern, "cmds") ) 764 dbgcCmdHelpCommands(pDbgc, pCmdHlp, &cHits); 765 else if ( !strcmp(pszPattern, "functions") 766 || !strcmp(pszPattern, "funcs") ) 767 dbgcCmdHelpFunctions(pDbgc, pCmdHlp, &cHits); 768 else if ( !strcmp(pszPattern, "operators") 769 || !strcmp(pszPattern, "ops") ) 770 dbgcCmdHelpOperators(pDbgc, pCmdHlp, &cHits); 778 771 else if (!strcmp(pszPattern, "all")) 779 { 780 rc = DBGCCmdHlpPrintf(pCmdHlp, 781 "VirtualBox Debugger Help\n" 782 "------------------------\n" 783 "\n"); 784 rc = dbgcCmdHelpCommands(pDbgc, pCmdHlp); 785 rc = DBGCCmdHlpPrintf(pCmdHlp, "\n"); 786 rc = dbgcCmdHelpFunctions(pDbgc, pCmdHlp); 787 rc = DBGCCmdHlpPrintf(pCmdHlp, "\n"); 788 rc = dbgcCmdHelpOperators(pDbgc, pCmdHlp); 789 } 772 dbgcCmdHelpAll(pDbgc, pCmdHlp, &cHits); 773 else if (!strcmp(pszPattern, "summary")) 774 dbgcCmdHelpSummary(pDbgc, pCmdHlp, &cHits); 775 /* Individual commands. */ 790 776 else 791 777 { 792 /* Individual commands. */ 793 bool fFound = false; 778 uint32_t const cPrevHits = cHits; 794 779 795 780 /* lookup in the emulation command list first */ … … 797 782 for (unsigned i = 0; i < aFixedCmds[j].cCmds; i++) 798 783 if (RTStrSimplePatternMatch(pszPattern, aFixedCmds[j].paCmds[i].pszCmd)) 799 { 800 rc = dbgcPrintHelpCmd(pCmdHlp, &aFixedCmds[j].paCmds[i], false); 801 fFound = true; 802 } 784 dbgcPrintHelpCmd(pCmdHlp, &aFixedCmds[j].paCmds[i], false, &cHits); 803 785 for (unsigned j = 0; j < RT_ELEMENTS(aFixedFuncs); j++) 804 786 for (unsigned i = 0; i < aFixedFuncs[j].cFuncs; i++) 805 787 if (RTStrSimplePatternMatch(pszPattern, aFixedFuncs[j].paFuncs[i].pszFuncNm)) 806 { 807 rc = dbgcPrintHelpFunction(pCmdHlp, &aFixedFuncs[j].paFuncs[i], false); 808 fFound = true; 809 } 788 dbgcPrintHelpFunction(pCmdHlp, &aFixedFuncs[j].paFuncs[i], false, &cHits); 810 789 811 790 /* external commands */ … … 820 799 for (unsigned i = 0; i < pExtCmd->cCmds; i++) 821 800 if (RTStrSimplePatternMatch(pszPattern2, pExtCmd->paCmds[i].pszCmd)) 822 { 823 rc = dbgcPrintHelpCmd(pCmdHlp, &pExtCmd->paCmds[i], true); 824 fFound = true; 825 } 801 dbgcPrintHelpCmd(pCmdHlp, &pExtCmd->paCmds[i], true, &cHits); 826 802 #if 0 827 803 for (PDBGCEXTFUNCS pExtFunc = g_pExtFuncsHead; pExtFunc; pExtFunc = pExtFunc->pNext) 828 804 for (unsigned i = 0; i < pExtFunc->cFuncs; i++) 829 805 if (RTStrSimplePatternMatch(pszPattern2, pExtFunc->paFuncs[i].pszFuncNm)) 830 { 831 rc = dbgcPrintHelpFunction(pCmdHlp, &pExtFunc->paFuncs[i], true); 832 fFound = true; 833 } 806 dbgcPrintHelpFunction(pCmdHlp, &pExtFunc->paFuncs[i], true, &cHits); 834 807 #endif 835 808 DBGCEXTLISTS_UNLOCK_RD(); … … 837 810 838 811 /* operators */ 839 if ( !fFound&& strlen(paArgs[iArg].u.pszString) < sizeof(g_aDbgcOps[0].szName))812 if (cHits == cPrevHits && strlen(paArgs[iArg].u.pszString) < sizeof(g_aDbgcOps[0].szName)) 840 813 for (unsigned i = 0; i < g_cDbgcOps && RT_SUCCESS(rc); i++) 841 814 if (RTStrSimplePatternMatch(pszPattern, g_aDbgcOps[i].szName)) 842 815 { 843 rc = DBGCCmdHlpPrintf(pCmdHlp, "%-10s %s %s\n",844 g_aDbgcOps[i].szName,845 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ",846 g_aDbgcOps[i].pszDescription);847 fFound = true;816 if (cHits++) 817 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 818 dbgcCmdHelpCmdOrFunc(pCmdHlp, g_aDbgcOps[i].szName, false, 819 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ", 820 g_aDbgcOps[i].pszDescription); 848 821 } 849 822 850 823 /* found? */ 851 if (!fFound) 852 rc = DBGCCmdHlpPrintf(pCmdHlp, "error: '%s' was not found!\n", 853 paArgs[iArg].u.pszString); 824 if (cHits == cPrevHits) 825 { 826 DBGCCmdHlpPrintf(pCmdHlp, "error: '%s' was not found!\n", 827 paArgs[iArg].u.pszString); 828 rc = VERR_DBGC_COMMAND_FAILED; 829 } 854 830 } 855 831 } /* foreach argument */
Note:
See TracChangeset
for help on using the changeset viewer.