VirtualBox

Changeset 35632 in vbox


Ignore:
Timestamp:
Jan 19, 2011 3:55:05 PM (14 years ago)
Author:
vboxsync
Message:

DBGC: Simplified the status code handling around dbgcEvalCommand.

Location:
trunk/src/VBox/Debugger
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCCmdHlp.cpp

    r35628 r35632  
    694694    if (RT_FAILURE(pDbgc->rcOutput))
    695695        return pDbgc->rcOutput;
    696 
    697     /** @todo DBGC: Implement failure / success on command level. */
    698     return VINF_SUCCESS;
     696    return VERR_DBGC_COMMAND_FAILED;
    699697}
    700698
  • trunk/src/VBox/Debugger/DBGCCmdWorkers.cpp

    r35628 r35632  
    375375 * @returns VERR_DBGC_BP_NOT_FOUND if the breakpoint wasn't found.
    376376 * @returns VERR_BUFFER_OVERFLOW if the is not enough space in the scratch buffer for the command.
    377  * @returns VBox status code from dbgcEvalCommand() other wise.
     377 * @returns VBox status code from dbgcEvalCommand() otherwise.
    378378 * @param   pDbgc       The DBGC instance.
    379379 * @param   iBp         The breakpoint to execute.
  • trunk/src/VBox/Debugger/DBGCEval.cpp

    r35628 r35632  
    9393
    9494    NOREF(pDbgc);
    95     return 0;
     95    return VINF_SUCCESS;
    9696}
    9797
     
    136136    pArg->u64Range      = 0;
    137137
    138     return 0;
     138    return VINF_SUCCESS;
    139139}
    140140
     
    356356 *      - Number to a pointer.
    357357 *      - Pointer to a number.
    358  * @returns 0 on success with paVars.
    359  * @returns VBox error code for match errors.
     358 *
     359 * @returns VBox status code. Modified @a paVars on success.
    360360 */
    361361static int dbgcEvalSubMatchVars(PDBGC pDbgc, unsigned cVarsMin, unsigned cVarsMax,
     
    432432    }
    433433
    434     return 0;
     434    return VINF_SUCCESS;
    435435}
    436436
     
    439439 * Evaluates one argument with respect to unary operators.
    440440 *
    441  * @returns 0 on success. pResult contains the result.
    442  * @returns VBox error code on parse or other evaluation error.
     441 * @returns VBox status code. pResult contains the result on success.
    443442 *
    444443 * @param   pDbgc       Debugger console instance data.
     
    458457     * ASSUME: unary operators are all of equal precedence.
    459458     */
    460     int         rc = 0;
     459    int         rc  = VINF_SUCCESS;
    461460    PCDBGCOP    pOp = dbgcOperatorLookup(pDbgc, pszExpr, false, ' ');
    462461    if (pOp)
     
    587586 * Evaluates one argument.
    588587 *
    589  * @returns 0 on success. pResult contains the result.
    590  * @returns VBox error code on parse or other evaluation error.
     588 * @returns VBox status code.
    591589 *
    592590 * @param   pDbgc       Debugger console instance data.
     
    787785 * Parses the arguments of one command.
    788786 *
    789  * @returns 0 on success.
    790  * @returns VBox error code on parse error with *pcArg containing the argument causing trouble.
     787 * @returns VBox statuc code. On parser errors the index of the troublesome
     788 *          argument is indicated by *pcArg.
     789 *
    791790 * @param   pDbgc       Debugger console instance data.
    792791 * @param   pCmd        Pointer to the command descriptor.
     
    794793 * @param   paArgs      Where to store the parsed arguments.
    795794 * @param   cArgs       Size of the paArgs array.
    796  * @param   pcArgs      Where to store the number of arguments.
    797  *                      In the event of an error this is used to store the index of the offending argument.
     795 * @param   pcArgs      Where to store the number of arguments.  In the event
     796 *                      of an error this is (ab)used to store the index of the
     797 *                      offending argument.
    798798 */
    799799static int dbgcProcessArguments(PDBGC pDbgc, PCDBGCCMD pCmd, char *pszArgs, PDBGCVAR paArgs, unsigned cArgs, unsigned *pcArgs)
    800800{
    801801    Log2(("dbgcProcessArguments: pCmd=%s pszArgs='%s'\n", pCmd->pszCmd, pszArgs));
     802
    802803    /*
    803804     * Check if we have any argument and if the command takes any.
     
    810811    {
    811812        if (!pCmd->cArgsMin)
    812             return 0;
     813            return VINF_SUCCESS;
    813814        return VERR_PARSE_TOO_FEW_ARGUMENTS;
    814815    }
     
    985986 * Evaluate one command.
    986987 *
    987  * @returns VBox status code. Any error indicates the termination of the console session.
     988 * @returns VBox status code. This is also stored in DBGC::rcCmd.
    988989 *
    989990 * @param   pDbgc       Debugger console instance data.
     
    991992 * @param   cchCmd      Length of the command.
    992993 * @param   fNoExecute  Indicates that no commands should actually be executed.
     994 *
    993995 * @todo    Change pszCmd into argc/argv?
    994996 */
     
    10041006
    10051007    /* external command? */
    1006     bool fExternal = *pszCmd == '.';
     1008    bool const fExternal = *pszCmd == '.';
    10071009    if (fExternal)
    10081010        pszCmd++, cchCmd--;
     
    10161018    if (*pszArgs && (!RT_C_IS_BLANK(*pszArgs) || pszArgs == pszCmd))
    10171019    {
    1018         pDbgc->rcCmd = VINF_PARSE_INVALD_COMMAND_NAME;
    1019         pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Syntax error in command '%s'!\n", pszCmdInput);
    1020         return 0;
     1020        DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "Syntax error: Invalid command '%s'!\n", pszCmdInput);
     1021        return pDbgc->rcCmd = VINF_PARSE_INVALD_COMMAND_NAME;
    10211022    }
    10221023
     
    10271028    if (!pCmd || (pCmd->fFlags & DBGCCMD_FLAGS_FUNCTION))
    10281029    {
    1029         pDbgc->rcCmd = VINF_PARSE_COMMAND_NOT_FOUND;
    1030         return pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Unknown command '%s'!\n", pszCmdInput);
     1030        DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "Syntax error: Unknown command '%s'!\n", pszCmdInput);
     1031        return pDbgc->rcCmd = VINF_PARSE_COMMAND_NOT_FOUND;
    10311032    }
    10321033
     
    10361037    unsigned cArgs;
    10371038    int rc = dbgcProcessArguments(pDbgc, pCmd, pszArgs, &pDbgc->aArgs[pDbgc->iArg], RT_ELEMENTS(pDbgc->aArgs) - pDbgc->iArg, &cArgs);
    1038 
    1039     /*
    1040      * Execute the command.
    1041      */
    1042     if (!rc)
    1043     {
     1039    if (RT_SUCCESS(rc))
     1040    {
     1041        AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n",  rc));
     1042
     1043        /*
     1044         * Execute the command.
     1045         */
    10441046        if (!fNoExecute)
    10451047            rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[0], cArgs, NULL);
     
    10561058        {
    10571059            case VERR_PARSE_TOO_FEW_ARGUMENTS:
    1058                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1060                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10591061                    "Syntax error: Too few arguments. Minimum is %d for command '%s'.\n", pCmd->cArgsMin, pCmd->pszCmd);
    10601062                break;
    10611063            case VERR_PARSE_TOO_MANY_ARGUMENTS:
    1062                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1064                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10631065                    "Syntax error: Too many arguments. Maximum is %d for command '%s'.\n", pCmd->cArgsMax, pCmd->pszCmd);
    10641066                break;
    10651067            case VERR_PARSE_ARGUMENT_OVERFLOW:
    1066                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1068                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10671069                    "Syntax error: Too many arguments.\n");
    10681070                break;
    10691071            case VERR_PARSE_UNBALANCED_QUOTE:
    1070                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1072                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10711073                    "Syntax error: Unbalanced quote (argument %d).\n", cArgs);
    10721074                break;
    10731075            case VERR_PARSE_UNBALANCED_PARENTHESIS:
    1074                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1076                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10751077                    "Syntax error: Unbalanced parenthesis (argument %d).\n", cArgs);
    10761078                break;
    10771079            case VERR_PARSE_EMPTY_ARGUMENT:
    1078                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1080                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10791081                    "Syntax error: An argument or subargument contains nothing useful (argument %d).\n", cArgs);
    10801082                break;
    10811083            case VERR_PARSE_UNEXPECTED_OPERATOR:
    1082                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1084                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10831085                    "Syntax error: Invalid operator usage (argument %d).\n", cArgs);
    10841086                break;
    10851087            case VERR_PARSE_INVALID_NUMBER:
    1086                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1088                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10871089                    "Syntax error: Ivalid numeric value (argument %d). If a string was the intention, then quote it.\n", cArgs);
    10881090                break;
    10891091            case VERR_PARSE_NUMBER_TOO_BIG:
    1090                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1092                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10911093                    "Error: Numeric overflow (argument %d).\n", cArgs);
    10921094                break;
    10931095            case VERR_PARSE_INVALID_OPERATION:
    1094                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1096                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10951097                    "Error: Invalid operation attempted (argument %d).\n", cArgs);
    10961098                break;
    10971099            case VERR_PARSE_FUNCTION_NOT_FOUND:
    1098                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1100                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    10991101                    "Error: Function not found (argument %d).\n", cArgs);
    11001102                break;
    11011103            case VERR_PARSE_NOT_A_FUNCTION:
    1102                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1104                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11031105                    "Error: The function specified is not a function (argument %d).\n", cArgs);
    11041106                break;
    11051107            case VERR_PARSE_NO_MEMORY:
    1106                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1108                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11071109                    "Error: Out memory in the regular heap! Expect odd stuff to happen...\n", cArgs);
    11081110                break;
    11091111            case VERR_PARSE_INCORRECT_ARG_TYPE:
    1110                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1112                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11111113                    "Error: Incorrect argument type (argument %d?).\n", cArgs);
    11121114                break;
    11131115            case VERR_PARSE_VARIABLE_NOT_FOUND:
    1114                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1116                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11151117                    "Error: An undefined variable was referenced (argument %d).\n", cArgs);
    11161118                break;
    11171119            case VERR_PARSE_CONVERSION_FAILED:
    1118                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1120                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11191121                    "Error: A conversion between two types failed (argument %d).\n", cArgs);
    11201122                break;
    11211123            case VERR_PARSE_NOT_IMPLEMENTED:
    1122                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1124                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11231125                    "Error: You hit a debugger feature which isn't implemented yet (argument %d).\n", cArgs);
    11241126                break;
    11251127            case VERR_PARSE_BAD_RESULT_TYPE:
    1126                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1128                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11271129                    "Error: Couldn't satisfy a request for a specific result type (argument %d). (Usually applies to symbols)\n", cArgs);
    11281130                break;
    11291131            case VERR_PARSE_WRITEONLY_SYMBOL:
    1130                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
     1132                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp,
    11311133                    "Error: Cannot get symbol, it's set only (argument %d).\n", cArgs);
    11321134                break;
    11331135
    11341136            case VERR_DBGC_COMMAND_FAILED:
    1135                 rc = VINF_SUCCESS;
    11361137                break;
    11371138
    11381139            default:
    1139                 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL,
    1140                     "Error: Unknown error %d!\n", rc);
    1141                 return rc;
     1140                rc = DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "Error: Unknown error %d!\n", rc);
     1141                break;
    11421142        }
    1143 
    1144         /*
    1145          * Parse errors are non fatal.
    1146          */
    1147         if (rc >= VERR_PARSE_FIRST && rc < VERR_PARSE_LAST)
    1148             rc = VINF_SUCCESS;
    1149     }
    1150 
     1143    }
    11511144    return rc;
    11521145}
  • trunk/src/VBox/Debugger/DBGConsole.cpp

    r35629 r35632  
    340340        pDbgc->iArg       = 0;
    341341        rc = dbgcEvalCommand(pDbgc, &pDbgc->achScratch[0], psz - &pDbgc->achScratch[0] - 1, fNoExecute);
    342         if (rc)
     342        if (   rc == VERR_DBGC_QUIT
     343            || rc == VWRN_DBGC_CMD_PENDING)
    343344            break;
    344345    }
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