- Timestamp:
- Jun 4, 2012 12:10:19 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/dbg.h
r41558 r41561 365 365 366 366 367 /** Pointer to command descriptor. */367 /** Pointer to a command descriptor. */ 368 368 typedef struct DBGCCMD *PDBGCCMD; 369 /** Pointer to const command descriptor. */369 /** Pointer to a const command descriptor. */ 370 370 typedef const struct DBGCCMD *PCDBGCCMD; 371 372 /** Pointer to a function descriptor. */ 373 typedef struct DBGCFUNC *PDBGCFUNC; 374 /** Pointer to a const function descriptor. */ 375 typedef const struct DBGCFUNC *PCDBGCFUNC; 371 376 372 377 /** Pointer to helper functions for commands. */ … … 887 892 /** 888 893 * DBGC command descriptor. 889 *890 * If a pResultDesc is specified the command can be called and used891 * as a function too. If it's a pure function, set fFlags to892 * DBGCCMD_FLAGS_FUNCTION.893 894 */ 894 895 typedef struct DBGCCMD … … 920 921 921 922 923 /** 924 * Function handler. 925 * 926 * The console will call the handler for a command once it's finished 927 * parsing the user input. The command handler function is responsible 928 * for executing the command itself. 929 * 930 * @returns VBox status. 931 * @param pCmd Pointer to the command descriptor (as registered). 932 * @param pCmdHlp Pointer to command helper functions. 933 * @param pVM Pointer to the current VM (if any). 934 * @param paArgs Pointer to (readonly) array of arguments. 935 * @param cArgs Number of arguments in the array. 936 * @param pResult Where to return the result. 937 */ 938 typedef DECLCALLBACK(int) FNDBGCFUNC(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, 939 PDBGCVAR pResult); 940 /** Pointer to a FNDBGCFUNC() function. */ 941 typedef FNDBGCFUNC *PFNDBGCFUNC; 942 943 /** 944 * DBGC function descriptor. 945 */ 946 typedef struct DBGCFUNC 947 { 948 /** Command string. */ 949 const char *pszFuncNm; 950 /** Minimum number of arguments. */ 951 unsigned cArgsMin; 952 /** Max number of arguments. */ 953 unsigned cArgsMax; 954 /** Argument descriptors (array). */ 955 PCDBGCVARDESC paArgDescs; 956 /** Number of argument descriptors. */ 957 unsigned cArgDescs; 958 /** flags. (reserved for now) */ 959 unsigned fFlags; 960 /** Handler function. */ 961 PFNDBGCFUNC pfnHandler; 962 /** Function syntax. */ 963 const char *pszSyntax; 964 /** Function description. */ 965 const char *pszDescription; 966 } DBGCFUNC; 967 968 922 969 923 970 /** Pointer to a DBGC backend. */ -
trunk/include/VBox/err.h
r41559 r41561 2166 2166 /** Syntax error - Command not found. */ 2167 2167 #define VERR_DBGC_PARSE_COMMAND_NOT_FOUND (VERR_DBGC_PARSE_LOWEST + 24) 2168 /** Syntax error - buggy parser. */ 2169 #define VERR_DBGC_PARSE_BUG (VERR_DBGC_PARSE_LOWEST + 25) 2168 2170 2169 2171 -
trunk/src/VBox/Debugger/DBGCCommands.cpp
r41553 r41561 5 5 6 6 /* 7 * Copyright (C) 2006-201 1Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 35 #include <iprt/ldr.h> 36 36 #include <iprt/mem.h> 37 #include <iprt/rand.h> 37 38 #include <iprt/path.h> 38 39 #include <iprt/string.h> … … 220 221 221 222 /** Command descriptors for the basic commands. */ 222 const DBGCCMD g_a Cmds[] =223 const DBGCCMD g_aDbgcCmds[] = 223 224 { 224 225 /* pszCmd, cArgsMin, cArgsMax, paArgDescs, cArgDescs, fFlags, pfnHandler pszSyntax, ....pszDescription */ … … 259 260 { "writecore", 1, 1, &g_aArgWriteCore[0], RT_ELEMENTS(g_aArgWriteCore), 0, dbgcCmdWriteCore, "<filename>", "Write core to file." }, 260 261 }; 261 262 262 /** The number of native commands. */ 263 const unsigned g_cCmds = RT_ELEMENTS(g_aCmds); 264 265 266 /** 267 * Pointer to head of the list of external commands. 268 */ 269 static PDBGCEXTCMDS g_pExtCmdsHead; /** @todo rw protect g_pExtCmdsHead! */ 270 /** Locks the g_pExtCmdsHead list for reading. */ 271 #define DBGCEXTCMDS_LOCK_RD() do { } while (0) 272 /** Locks the g_pExtCmdsHead list for writing. */ 273 #define DBGCEXTCMDS_LOCK_WR() do { } while (0) 274 /** UnLocks the g_pExtCmdsHead list after reading. */ 275 #define DBGCEXTCMDS_UNLOCK_RD() do { } while (0) 276 /** UnLocks the g_pExtCmdsHead list after writing. */ 277 #define DBGCEXTCMDS_UNLOCK_WR() do { } while (0) 263 const uint32_t g_cDbgcCmds = RT_ELEMENTS(g_aDbgcCmds); 264 /** Pointer to head of the list of external commands. */ 265 static PDBGCEXTCMDS g_pExtCmdsHead; 278 266 279 267 … … 292 280 * @param fExternal Whether or not the routine is external. 293 281 */ 294 PCDBGCCMD dbgc RoutineLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal)282 PCDBGCCMD dbgcCommandLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal) 295 283 { 296 284 if (!fExternal) … … 307 295 } 308 296 309 for (unsigned iCmd = 0; iCmd < RT_ELEMENTS(g_a Cmds); iCmd++)310 { 311 if ( !strncmp(pachName, g_a Cmds[iCmd].pszCmd, cchName)312 && !g_a Cmds[iCmd].pszCmd[cchName])313 return &g_a Cmds[iCmd];297 for (unsigned iCmd = 0; iCmd < RT_ELEMENTS(g_aDbgcCmds); iCmd++) 298 { 299 if ( !strncmp(pachName, g_aDbgcCmds[iCmd].pszCmd, cchName) 300 && !g_aDbgcCmds[iCmd].pszCmd[cchName]) 301 return &g_aDbgcCmds[iCmd]; 314 302 } 315 303 } 316 304 else 317 305 { 318 DBGCEXT CMDS_LOCK_RD();306 DBGCEXTLISTS_LOCK_RD(); 319 307 for (PDBGCEXTCMDS pExtCmds = g_pExtCmdsHead; pExtCmds; pExtCmds = pExtCmds->pNext) 320 308 { … … 326 314 } 327 315 } 328 DBGCEXTCMDS_UNLOCK_RD(); 329 } 330 331 NOREF(pDbgc); 316 DBGCEXTLISTS_UNLOCK_RD(); 317 } 318 332 319 return NULL; 333 320 } … … 348 335 * Lock the list. 349 336 */ 350 DBGCEXT CMDS_LOCK_WR();337 DBGCEXTLISTS_LOCK_WR(); 351 338 PDBGCEXTCMDS pCur = g_pExtCmdsHead; 352 339 while (pCur) … … 354 341 if (paCommands == pCur->paCmds) 355 342 { 356 DBGCEXT CMDS_UNLOCK_WR();343 DBGCEXTLISTS_UNLOCK_WR(); 357 344 AssertMsgFailed(("Attempt at re-registering %d command(s)!\n", cCommands)); 358 345 return VWRN_DBGC_ALREADY_REGISTERED; … … 375 362 else 376 363 rc = VERR_NO_MEMORY; 377 DBGCEXT CMDS_UNLOCK_WR();364 DBGCEXTLISTS_UNLOCK_WR(); 378 365 379 366 return rc; … … 395 382 * Lock the list. 396 383 */ 397 DBGCEXT CMDS_LOCK_WR();384 DBGCEXTLISTS_LOCK_WR(); 398 385 PDBGCEXTCMDS pPrev = NULL; 399 386 PDBGCEXTCMDS pCur = g_pExtCmdsHead; … … 406 393 else 407 394 g_pExtCmdsHead = pCur->pNext; 408 DBGCEXT CMDS_UNLOCK_WR();395 DBGCEXTLISTS_UNLOCK_WR(); 409 396 410 397 RTMemFree(pCur); … … 414 401 pCur = pCur->pNext; 415 402 } 416 DBGCEXT CMDS_UNLOCK_WR();403 DBGCEXTLISTS_UNLOCK_WR(); 417 404 418 405 NOREF(cCommands); … … 498 485 "-------------------\n" 499 486 "\n" 500 "Commands and Functions:\n");501 for (i = 0; i < RT_ELEMENTS(g_a Cmds); i++)487 "Commands:\n"); 488 for (i = 0; i < RT_ELEMENTS(g_aDbgcCmds); i++) 502 489 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 503 490 "%-11s %-30s %s\n", 504 g_a Cmds[i].pszCmd,505 g_a Cmds[i].pszSyntax,506 g_a Cmds[i].pszDescription);491 g_aDbgcCmds[i].pszCmd, 492 g_aDbgcCmds[i].pszSyntax, 493 g_aDbgcCmds[i].pszDescription); 507 494 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 508 495 "\n" … … 518 505 if (g_pExtCmdsHead) 519 506 { 520 DBGCEXT CMDS_LOCK_RD();507 DBGCEXTLISTS_LOCK_RD(); 521 508 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 522 509 "\n" 523 "External Commands and Functions:\n");510 "External Commands:\n"); 524 511 for (PDBGCEXTCMDS pExtCmd = g_pExtCmdsHead; pExtCmd; pExtCmd = pExtCmd->pNext) 525 512 for (i = 0; i < pExtCmd->cCmds; i++) … … 529 516 pExtCmd->paCmds[i].pszSyntax, 530 517 pExtCmd->paCmds[i].pszDescription); 531 DBGCEXTCMDS_UNLOCK_RD(); 532 } 518 DBGCEXTLISTS_UNLOCK_RD(); 519 } 520 521 533 522 534 523 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, … … 536 525 "Operators:\n"); 537 526 unsigned iPrecedence = 0; 538 unsigned cLeft = g_c Ops;527 unsigned cLeft = g_cDbgcOps; 539 528 while (cLeft > 0) 540 529 { 541 for (i = 0; i < g_c Ops; i++)542 if (g_a Ops[i].iPrecedence == iPrecedence)530 for (i = 0; i < g_cDbgcOps; i++) 531 if (g_aDbgcOps[i].iPrecedence == iPrecedence) 543 532 { 544 533 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 545 534 "%-10s %s %s\n", 546 g_a Ops[i].szName,547 g_a Ops[i].fBinary ? "Binary" : "Unary ",548 g_a Ops[i].pszDescription);535 g_aDbgcOps[i].szName, 536 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ", 537 g_aDbgcOps[i].pszDescription); 549 538 cLeft--; 550 539 } … … 572 561 573 562 /* lookup in the command list (even when found in the emulation) */ 574 for (i = 0; i < RT_ELEMENTS(g_a Cmds); i++)575 if (RTStrSimplePatternMatch(pszPattern, g_a Cmds[i].pszCmd))563 for (i = 0; i < RT_ELEMENTS(g_aDbgcCmds); i++) 564 if (RTStrSimplePatternMatch(pszPattern, g_aDbgcCmds[i].pszCmd)) 576 565 { 577 rc = dbgcPrintHelp(pCmdHlp, &g_a Cmds[i], false);566 rc = dbgcPrintHelp(pCmdHlp, &g_aDbgcCmds[i], false); 578 567 fFound = true; 579 568 } … … 586 575 || *pszPattern == '*')) 587 576 { 588 DBGCEXT CMDS_LOCK_RD();577 DBGCEXTLISTS_LOCK_RD(); 589 578 const char *pszPattern2 = pszPattern + (*pszPattern == '.' || *pszPattern == '?'); 590 579 for (PDBGCEXTCMDS pExtCmd = g_pExtCmdsHead; pExtCmd; pExtCmd = pExtCmd->pNext) … … 595 584 fFound = true; 596 585 } 597 DBGCEXT CMDS_UNLOCK_RD();586 DBGCEXTLISTS_UNLOCK_RD(); 598 587 } 599 588 600 589 /* operators */ 601 if (!fFound && strlen(paArgs[iArg].u.pszString) < sizeof(g_a Ops[i].szName))590 if (!fFound && strlen(paArgs[iArg].u.pszString) < sizeof(g_aDbgcOps[i].szName)) 602 591 { 603 for (i = 0; i < g_c Ops; i++)604 if (RTStrSimplePatternMatch(pszPattern, g_a Ops[i].szName))592 for (i = 0; i < g_cDbgcOps; i++) 593 if (RTStrSimplePatternMatch(pszPattern, g_aDbgcOps[i].szName)) 605 594 { 606 595 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, 607 596 "%-10s %s %s\n", 608 g_a Ops[i].szName,609 g_a Ops[i].fBinary ? "Binary" : "Unary ",610 g_a Ops[i].pszDescription);597 g_aDbgcOps[i].szName, 598 g_aDbgcOps[i].fBinary ? "Binary" : "Unary ", 599 g_aDbgcOps[i].pszDescription); 611 600 fFound = true; 612 601 } … … 2103 2092 } 2104 2093 2094 2095 2096 /** 2097 * @callback_method_impl{The randu32() function implementation.} 2098 */ 2099 static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs, 2100 PDBGCVAR pResult) 2101 { 2102 AssertReturn(cArgs == 0, VERR_DBGC_PARSE_BUG); 2103 uint32_t u32 = RTRandU32(); 2104 DBGCVAR_INIT_NUMBER(pResult, u32); 2105 NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); NOREF(paArgs); 2106 return VINF_SUCCESS; 2107 } 2108 -
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r41542 r41561 368 368 369 369 /** The number of commands in the CodeView/WinDbg emulation. */ 370 const unsigned g_cCmdsCodeView = RT_ELEMENTS(g_aCmdsCodeView); 371 370 const uint32_t g_cCmdsCodeView = RT_ELEMENTS(g_aCmdsCodeView); 371 372 373 /** Function descriptors for the CodeView / WinDbg emulation. 374 * The emulation isn't attempting to be identical, only somewhat similar. 375 */ 376 const DBGCFUNC g_aFuncsCodeView[] = 377 { 378 }; 379 380 /** The number of functions in the CodeView/WinDbg emulation. */ 381 const uint32_t g_cFuncsCodeView = RT_ELEMENTS(g_aFuncsCodeView); 372 382 373 383 -
trunk/src/VBox/Debugger/DBGCEval.cpp
r41559 r41561 43 43 44 44 45 /******************************************************************************* 46 * Internal Functions * 47 *******************************************************************************/ 48 static int dbgcProcessArguments(PDBGC pDbgc, const char *pszCmdOrFunc, 49 uint32_t const cArgsMin, uint32_t const cArgsMax, 50 PCDBGCVARDESC const paVarDescs, uint32_t const cVarDescs, 51 char *pszArgs, unsigned *piArg, unsigned *pcArgs); 52 53 45 54 46 55 /** … … 50 59 { 51 60 memset(g_bmOperatorChars, 0, sizeof(g_bmOperatorChars)); 52 for (unsigned iOp = 0; iOp < g_c Ops; iOp++)53 ASMBitSet(&g_bmOperatorChars[0], (uint8_t)g_a Ops[iOp].szName[0]);61 for (unsigned iOp = 0; iOp < g_cDbgcOps; iOp++) 62 ASMBitSet(&g_bmOperatorChars[0], (uint8_t)g_aDbgcOps[iOp].szName[0]); 54 63 } 55 64 … … 312 321 313 322 323 static int dbgcEvalSubCall(PDBGC pDbgc, char *pszFuncNm, size_t cchFuncNm, bool fExternal, char *pszArgs, size_t cchArgs, 324 DBGCVARCAT enmCategory, PDBGCVAR pResult) 325 { 326 /* 327 * Lookup the function. 328 */ 329 PCDBGCFUNC pFunc = dbgcFunctionLookup(pDbgc, pszFuncNm, cchFuncNm, fExternal); 330 if (!pFunc) 331 return VERR_DBGC_PARSE_FUNCTION_NOT_FOUND; 332 333 /* 334 * Parse the arguments. 335 */ 336 unsigned cArgs; 337 unsigned iArg; 338 pszArgs[cchArgs] = '\0'; 339 int rc = dbgcProcessArguments(pDbgc, pFunc->pszFuncNm, 340 pFunc->cArgsMin, pFunc->cArgsMax, pFunc->paArgDescs, pFunc->cArgDescs, 341 pszArgs, &iArg, &cArgs); 342 if (RT_SUCCESS(rc)) 343 rc = pFunc->pfnHandler(pFunc, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[iArg], cArgs, pResult); 344 pDbgc->iArg = iArg; 345 return rc; 346 } 347 348 314 349 /** 315 350 * Evaluates one argument with respect to unary operators. … … 389 424 if (pszFunEnd) 390 425 { 391 /* 392 * Ok, it's a function call. 393 */ 394 if (fExternal) 395 pszExpr++, cchExpr--; 396 PCDBGCCMD pFun = dbgcRoutineLookup(pDbgc, pszExpr, pszFunEnd - pszExpr, fExternal); 397 if (!pFun) 398 return VERR_DBGC_PARSE_FUNCTION_NOT_FOUND; 399 #if 0 400 if (!pFun->pResultDesc) 401 return VERR_DBGC_PARSE_NOT_A_FUNCTION; 402 403 /* 404 * Parse the expression in parenthesis. 405 */ 406 cchExpr -= pszFunEnd - pszExpr; 407 pszExpr = pszFunEnd; 408 /** @todo implement multiple arguments. */ 409 DBGCVAR Arg; 410 rc = dbgcEvalSub(pDbgc, pszExpr, cchExpr, enmCategory, &Arg); 411 if (!rc) 412 { 413 rc = dbgcEvalSubMatchVars(pDbgc, pFun->cArgsMin, pFun->cArgsMax, pFun->paArgDescs, pFun->cArgDescs, &Arg, 1); 414 if (!rc) 415 rc = pFun->pfnHandler(pFun, &pDbgc->CmdHlp, pDbgc->pVM, &Arg, 1, pResult); 416 } 417 else if (rc == VERR_DBGC_PARSE_EMPTY_ARGUMENT && pFun->cArgsMin == 0) 418 rc = pFun->pfnHandler(pFun, &pDbgc->CmdHlp, pDbgc->pVM, NULL, 0, pResult); 419 #else 420 rc = VERR_NOT_IMPLEMENTED; 421 #endif 422 return rc; 426 size_t cchFunNm = pszFunEnd - pszFun; 427 return dbgcEvalSubCall(pDbgc, pszFun, cchFunNm, fExternal, pszFunEnd + 1, cchExpr - cchFunNm - fExternal - 2, 428 enmCategory, pResult); 423 429 } 424 430 … … 591 597 else if (ch == '(') 592 598 { 593 if (!cPar && (fBinary || cchWord)) /** @todo function call */599 if (!cPar && fBinary && !cchWord) 594 600 return VERR_DBGC_PARSE_EXPECTED_BINARY_OP; 595 601 cPar++; … … 936 942 * argument is indicated by *pcArg. 937 943 * 938 * @param pDbgc Debugger console instance data. 939 * @param pCmd Pointer to the command descriptor. 940 * @param pszArg Pointer to the arguments to parse. 941 * @param paArgs Where to store the parsed arguments. 942 * @param cArgs Size of the paArgs array. 943 * @param pcArgs Where to store the number of arguments. In the event 944 * of an error this is (ab)used to store the index of the 945 * offending argument. 944 * @param pDbgc Debugger console instance data. 945 * @param pszCmdOrFunc The name of the function or command. (For logging.) 946 * @param cArgsMin See DBGCCMD::cArgsMin and DBGCFUNC::cArgsMin. 947 * @param cArgsMax See DBGCCMD::cArgsMax and DBGCFUNC::cArgsMax. 948 * @param paVarDescs See DBGCCMD::paVarDescs and DBGCFUNC::paVarDescs. 949 * @param cVarDescs See DBGCCMD::cVarDescs and DBGCFUNC::cVarDescs. 950 * @param pszArg Pointer to the arguments to parse. 951 * @param piArg Where to return the index of the first argument in 952 * DBGC::aArgs. Always set. Caller must restore DBGC::iArg 953 * to this value when done, even on failure. 954 * @param pcArgs Where to store the number of arguments. In the event 955 * of an error this is (ab)used to store the index of the 956 * offending argument. 946 957 */ 947 static int dbgcProcessArguments(PDBGC pDbgc, PCDBGCCMD pCmd, char *pszArgs, PDBGCVAR paArgs, unsigned cArgs, unsigned *pcArgs) 958 static int dbgcProcessArguments(PDBGC pDbgc, const char *pszCmdOrFunc, 959 uint32_t const cArgsMin, uint32_t const cArgsMax, 960 PCDBGCVARDESC const paVarDescs, uint32_t const cVarDescs, 961 char *pszArgs, unsigned *piArg, unsigned *pcArgs) 948 962 { 949 Log2(("dbgcProcessArguments: p Cmd=%s pszArgs='%s'\n", pCmd->pszCmd, pszArgs));963 Log2(("dbgcProcessArguments: pszCmdOrFunc=%s pszArgs='%s'\n", pszCmdOrFunc, pszArgs)); 950 964 951 965 /* 952 966 * Check if we have any argument and if the command takes any. 953 967 */ 968 *piArg = pDbgc->iArg; 954 969 *pcArgs = 0; 955 970 /* strip leading blanks. */ … … 958 973 if (!*pszArgs) 959 974 { 960 if (! pCmd->cArgsMin)975 if (!cArgsMin) 961 976 return VINF_SUCCESS; 962 977 return VERR_DBGC_PARSE_TOO_FEW_ARGUMENTS; 963 978 } 964 /** @todo fixme - foo() doesn't work. */ 965 if (!pCmd->cArgsMax) 979 if (!cArgsMax) 966 980 return VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS; 967 981 … … 969 983 * The parse loop. 970 984 */ 971 PDBGCVAR pArg0 = &paArgs[0]; 972 PDBGCVAR pArg = pArg0; 985 PDBGCVAR pArg = &pDbgc->aArgs[pDbgc->iArg]; 973 986 PCDBGCVARDESC pPrevDesc = NULL; 974 PCDBGCVARDESC paVarDescs = pCmd->paArgDescs;975 unsigned const cVarDescs = pCmd->cArgDescs;976 987 unsigned cCurDesc = 0; 977 988 unsigned iVar = 0; … … 983 994 * Can we have another argument? 984 995 */ 985 if (*pcArgs >= pCmd->cArgsMax)996 if (*pcArgs >= cArgsMax) 986 997 return VERR_DBGC_PARSE_TOO_MANY_ARGUMENTS; 987 if (p Arg >= &paArgs[cArgs])998 if (pDbgc->iArg >= RT_ELEMENTS(pDbgc->aArgs)) 988 999 return VERR_DBGC_PARSE_ARGUMENT_OVERFLOW; 989 1000 if (iVarDesc >= cVarDescs) … … 1051 1062 else if (ch == '(') 1052 1063 { 1053 if (!cPar && fBinary)1054 return VERR_DBGC_PARSE_EXPECTED_BINARY_OP;1055 1064 cPar++; 1056 1065 fBinary = false; … … 1181 1190 iVar++; 1182 1191 pArg++; 1183 (*pcArgs)++; 1192 pDbgc->iArg++; 1193 *pcArgs += 1; 1184 1194 pszArgs = psz; 1185 1195 while (*pszArgs && RT_C_IS_BLANK(*pszArgs)) … … 1249 1259 * Find the command. 1250 1260 */ 1251 PCDBGCCMD pCmd = dbgc RoutineLookup(pDbgc, pszCmd, pszArgs - pszCmd, fExternal);1261 PCDBGCCMD pCmd = dbgcCommandLookup(pDbgc, pszCmd, pszArgs - pszCmd, fExternal); 1252 1262 if (!pCmd) 1253 1263 { … … 1259 1269 * Parse arguments (if any). 1260 1270 */ 1271 unsigned iArg; 1261 1272 unsigned cArgs; 1262 int rc = dbgcProcessArguments(pDbgc, pCmd, pszArgs, &pDbgc->aArgs[pDbgc->iArg], 1263 RT_ELEMENTS(pDbgc->aArgs) - pDbgc->iArg, &cArgs); 1273 int rc = dbgcProcessArguments(pDbgc, pCmd->pszCmd, 1274 pCmd->cArgsMin, pCmd->cArgsMax, pCmd->paArgDescs, pCmd->cArgDescs, 1275 pszArgs, &iArg, &cArgs); 1264 1276 if (RT_SUCCESS(rc)) 1265 1277 { … … 1270 1282 */ 1271 1283 if (!fNoExecute) 1272 rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[ 0], cArgs);1284 rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[iArg], cArgs); 1273 1285 pDbgc->rcCmd = rc; 1286 pDbgc->iArg = iArg; 1274 1287 if (rc == VERR_DBGC_COMMAND_FAILED) 1275 1288 rc = VINF_SUCCESS; … … 1278 1291 { 1279 1292 pDbgc->rcCmd = rc; 1293 pDbgc->iArg = iArg; 1280 1294 1281 1295 /* report parse / eval error. */ … … 1373 1387 } 1374 1388 } 1389 1375 1390 return rc; 1376 1391 } -
trunk/src/VBox/Debugger/DBGCInternal.h
r41553 r41561 118 118 /** The current debugger emulation. */ 119 119 const char *pszEmulation; 120 /** Pointer to the command and functions for the current debugger emulation. */120 /** Pointer to the commands for the current debugger emulation. */ 121 121 PCDBGCCMD paEmulationCmds; 122 122 /** The number of commands paEmulationCmds points to. */ 123 123 unsigned cEmulationCmds; 124 /** Pointer to the functions for the current debugger emulation. */ 125 PCDBGCFUNC paEmulationFuncs; 126 /** The number of functions paEmulationFuncs points to. */ 127 uint32_t cEmulationFuncs; 124 128 /** Log indicator. (If set we're writing the log to the console.) */ 125 129 bool fLog; … … 227 231 /** Pointer to chunk of external commands. */ 228 232 typedef DBGCEXTCMDS *PDBGCEXTCMDS; 233 234 235 /** 236 * Chunk of external functions. 237 */ 238 typedef struct DBGCEXTFUNCS 239 { 240 /** Number of functions descriptors. */ 241 uint32_t cFuncs; 242 /** Pointer to array of functions descriptors. */ 243 PCDBGCFUNC paFuncs; 244 /** Pointer to the next chunk. */ 245 struct DBGCEXTFUNCS *pNext; 246 } DBGCEXTFUNCS; 247 /** Pointer to chunk of external functions. */ 248 typedef DBGCEXTFUNCS *PDBGCEXTFUNCS; 229 249 230 250 … … 363 383 PCDBGCSYM dbgcLookupRegisterSymbol(PDBGC pDbgc, const char *pszSymbol); 364 384 PCDBGCOP dbgcOperatorLookup(PDBGC pDbgc, const char *pszExpr, bool fPreferBinary, char chPrev); 365 PCDBGCCMD dbgcRoutineLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal); 385 PCDBGCCMD dbgcCommandLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal); 386 PCDBGCFUNC dbgcFunctionLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal); 366 387 367 388 DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult); … … 386 407 * Global Variables * 387 408 *******************************************************************************/ 388 extern const DBGCCMD g_aCmds[]; 389 extern const unsigned g_cCmds; 409 extern const DBGCCMD g_aDbgcCmds[]; 410 extern const uint32_t g_cDbgcCmds; 411 extern const DBGCFUNC g_aDbgcFuncs[]; 412 extern const uint32_t g_cDbgcFuncs; 390 413 extern const DBGCCMD g_aCmdsCodeView[]; 391 extern const unsigned g_cCmdsCodeView; 392 extern const DBGCOP g_aOps[]; 393 extern const unsigned g_cOps; 414 extern const uint32_t g_cCmdsCodeView; 415 extern const DBGCFUNC g_aFuncsCodeView[]; 416 extern const uint32_t g_cFuncsCodeView; 417 extern const DBGCOP g_aDbgcOps[]; 418 extern const uint32_t g_cDbgcOps; 419 420 421 /******************************************************************************* 422 * Defined Constants And Macros * 423 *******************************************************************************/ 424 /** Locks the g_pExtCmdsHead and g_pExtFuncsHead lists for reading. */ 425 #define DBGCEXTLISTS_LOCK_RD() do { } while (0) 426 /** Locks the g_pExtCmdsHead and g_pExtFuncsHead lists for writing. */ 427 #define DBGCEXTLISTS_LOCK_WR() do { } while (0) 428 /** UnLocks the g_pExtCmdsHead and g_pExtFuncsHead lists after reading. */ 429 #define DBGCEXTLISTS_UNLOCK_RD() do { } while (0) 430 /** UnLocks the g_pExtCmdsHead and g_pExtFuncsHead lists after writing. */ 431 #define DBGCEXTLISTS_UNLOCK_WR() do { } while (0) 432 394 433 395 434 -
trunk/src/VBox/Debugger/DBGCOps.cpp
r41553 r41561 152 152 *******************************************************************************/ 153 153 /** Operators. */ 154 const DBGCOP g_a Ops[] =154 const DBGCOP g_aDbgcOps[] = 155 155 { 156 156 /* szName is initialized as a 4 char array because of M$C elsewise optimizing it away in /Ox mode (the 'const char' vs 'char' problem). */ … … 185 185 186 186 /** Number of operators in the operator array. */ 187 const u nsigned g_cOps = RT_ELEMENTS(g_aOps);187 const uint32_t g_cDbgcOps = RT_ELEMENTS(g_aDbgcOps); 188 188 189 189 … … 1400 1400 { 1401 1401 PCDBGCOP pOp = NULL; 1402 for (unsigned iOp = 0; iOp < RT_ELEMENTS(g_a Ops); iOp++)1403 { 1404 if ( g_a Ops[iOp].szName[0] == pszExpr[0]1405 && (!g_a Ops[iOp].szName[1] || g_aOps[iOp].szName[1] == pszExpr[1])1406 && (!g_a Ops[iOp].szName[2] || g_aOps[iOp].szName[2] == pszExpr[2]))1402 for (unsigned iOp = 0; iOp < RT_ELEMENTS(g_aDbgcOps); iOp++) 1403 { 1404 if ( g_aDbgcOps[iOp].szName[0] == pszExpr[0] 1405 && (!g_aDbgcOps[iOp].szName[1] || g_aDbgcOps[iOp].szName[1] == pszExpr[1]) 1406 && (!g_aDbgcOps[iOp].szName[2] || g_aDbgcOps[iOp].szName[2] == pszExpr[2])) 1407 1407 { 1408 1408 /* … … 1410 1410 */ 1411 1411 unsigned j; 1412 for (j = iOp + 1; j < RT_ELEMENTS(g_a Ops); j++)1413 if ( g_a Ops[j].cchName > g_aOps[iOp].cchName1414 && g_a Ops[j].szName[0] == pszExpr[0]1415 && (!g_a Ops[j].szName[1] || g_aOps[j].szName[1] == pszExpr[1])1416 && (!g_a Ops[j].szName[2] || g_aOps[j].szName[2] == pszExpr[2]) )1412 for (j = iOp + 1; j < RT_ELEMENTS(g_aDbgcOps); j++) 1413 if ( g_aDbgcOps[j].cchName > g_aDbgcOps[iOp].cchName 1414 && g_aDbgcOps[j].szName[0] == pszExpr[0] 1415 && (!g_aDbgcOps[j].szName[1] || g_aDbgcOps[j].szName[1] == pszExpr[1]) 1416 && (!g_aDbgcOps[j].szName[2] || g_aDbgcOps[j].szName[2] == pszExpr[2]) ) 1417 1417 break; 1418 if (j < RT_ELEMENTS(g_a Ops))1418 if (j < RT_ELEMENTS(g_aDbgcOps)) 1419 1419 continue; /* we'll catch it later. (for theoretical +,++,+++ cases.) */ 1420 pOp = &g_a Ops[iOp];1420 pOp = &g_aDbgcOps[iOp]; 1421 1421 1422 1422 /* 1423 1423 * Preferred type? 1424 1424 */ 1425 if (g_a Ops[iOp].fBinary == fPreferBinary)1425 if (g_aDbgcOps[iOp].fBinary == fPreferBinary) 1426 1426 break; 1427 1427 } -
trunk/src/VBox/Debugger/DBGConsole.cpp
r41553 r41561 868 868 pDbgc->paEmulationCmds = &g_aCmdsCodeView[0]; 869 869 pDbgc->cEmulationCmds = g_cCmdsCodeView; 870 pDbgc->paEmulationFuncs = &g_aFuncsCodeView[0]; 871 pDbgc->cEmulationFuncs = g_cFuncsCodeView; 870 872 //pDbgc->fLog = false; 871 873 pDbgc->fRegCtxGuest = true; -
trunk/src/VBox/Debugger/Makefile.kmk
r41477 r41561 47 47 DBGCCmdHlp.cpp \ 48 48 DBGCCmdWorkers.cpp \ 49 DBGCCommands.cpp \ 49 DBGCCommands.cpp \ 50 DBGCFunctions.cpp \ 50 51 DBGCEmulateCodeView.cpp \ 51 52 DBGCOps.cpp \ -
trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
r41559 r41561 1136 1136 tstTry(pDbgc, "format (1)(1)\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP); 1137 1137 tstTry(pDbgc, "format (1)''\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP); 1138 tstTry(pDbgc, "format foo(1)\n", VERR_DBGC_PARSE_EXPECTED_BINARY_OP); /** @todo VERR_DBGC_PARSE_FUNCTION_NOT_FOUND */ 1138 tstTry(pDbgc, "format nosuchfunction(1)\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND); 1139 tstTry(pDbgc, "format nosuchfunction(1,2,3)\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND); 1140 tstTry(pDbgc, "format nosuchfunction()\n", VERR_DBGC_PARSE_FUNCTION_NOT_FOUND); 1141 tstTry(pDbgc, "format randu32()\n", VINF_SUCCESS); 1139 1142 tstTry(pDbgc, "sa 3 23 4 'q' \"21123123\" 'b' \n", VINF_SUCCESS); 1140 1143 tstTry(pDbgc, "sa 3,23, 4,'q' ,\"21123123\" , 'b' \n", VINF_SUCCESS);
Note:
See TracChangeset
for help on using the changeset viewer.