- Timestamp:
- Nov 11, 2007 12:22:14 PM (17 years ago)
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCmdHlp.cpp
r5676 r5686 559 559 */ 560 560 pDbgc->pszScratch = pDbgc->pszScratch + cb + 1; 561 int rc = dbgcProcessCommand(pDbgc, pszScratch, cb );561 int rc = dbgcProcessCommand(pDbgc, pszScratch, cb, false /* fNoExecute */); 562 562 563 563 /* Restore the scratch state. */ -
trunk/src/VBox/Debugger/DBGCCmdWorkers.cpp
r5677 r5686 346 346 /* Execute the command. */ 347 347 pDbgc->pszScratch = pDbgc->pszScratch + pBp->cchCmd + 1; 348 int rc = dbgcProcessCommand(pDbgc, pszScratch, pBp->cchCmd );348 int rc = dbgcProcessCommand(pDbgc, pszScratch, pBp->cchCmd, false /* fNoExecute */); 349 349 350 350 /* Restore the scratch state. */ -
trunk/src/VBox/Debugger/DBGCInternal.h
r5685 r5686 54 54 #define VERR_PARSE_WRITEONLY_SYMBOL (VERR_PARSE_FIRST - 20) 55 55 #define VERR_PARSE_NO_ARGUMENT_MATCH (VERR_PARSE_FIRST - 21) 56 #define VINF_PARSE_COMMAND_NOT_FOUND (VERR_PARSE_FIRST - 22) 57 #define VINF_PARSE_INVALD_COMMAND_NAME (VERR_PARSE_FIRST - 23) 56 58 #define VERR_PARSE_LAST (VERR_PARSE_FIRST - 30) 57 59 … … 186 188 DBGCVAR aArgs[100]; 187 189 188 /** rc from last dbgcHlpPrintfV(). */190 /** rc from the last dbgcHlpPrintfV(). */ 189 191 int rcOutput; 190 192 /** rc from the last command. */ 193 int rcCmd; 191 194 /** @} */ 192 195 } DBGC; … … 328 331 * Internal Functions * 329 332 *******************************************************************************/ 330 int dbgcCreate(PDBGC *ppDbgc, PDBGCBACK pBack, unsigned fFlags);331 int dbgcRun(PDBGC pDbgc);332 void dbgcDestroy(PDBGC pDbgc);333 334 333 int dbgcBpAdd(PDBGC pDbgc, RTUINT iBp, const char *pszCmd); 335 334 int dbgcBpUpdate(PDBGC pDbgc, RTUINT iBp, const char *pszCmd); … … 346 345 347 346 int dbgcEvalSub(PDBGC pDbgc, char *pszExpr, size_t cchExpr, PDBGCVAR pResult); 348 int dbgcProcessCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd );347 int dbgcProcessCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd, bool fNoExecute); 349 348 350 349 int dbgcSymbolGet(PDBGC pDbgc, const char *pszSymbol, DBGCVARTYPE enmType, PDBGCVAR pResult); … … 359 358 360 359 void dbgcInitCmdHlp(PDBGC pDbgc); 360 361 /* For tstDBGCParser: */ 362 int dbgcCreate(PDBGC *ppDbgc, PDBGCBACK pBack, unsigned fFlags); 363 int dbgcRun(PDBGC pDbgc); 364 int dbgcProcessInput(PDBGC pDbgc, bool fNoExecute); 365 void dbgcDestroy(PDBGC pDbgc); 361 366 362 367 -
trunk/src/VBox/Debugger/DBGConsole.cpp
r5685 r5686 1203 1203 * 1204 1204 * @returns VBox status code. Any error indicates the termination of the console session. 1205 * @param pDbgc Debugger console instance data. 1206 * @param pszCmd Pointer to the command. 1207 * @param cchCmd Length of the command. 1208 */ 1209 int dbgcProcessCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd) 1205 * @param pDbgc Debugger console instance data. 1206 * @param pszCmd Pointer to the command. 1207 * @param cchCmd Length of the command. 1208 * @param fNoExecute Indicates that no commands should actually be executed. 1209 */ 1210 int dbgcProcessCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd, bool fNoExecute) 1210 1211 { 1211 1212 char *pszCmdInput = pszCmd; … … 1230 1231 if (*pszArgs && (!isblank(*pszArgs) || pszArgs == pszCmd)) 1231 1232 { 1233 pDbgc->rcCmd = VINF_PARSE_INVALD_COMMAND_NAME; 1232 1234 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Syntax error in command '%s'!\n", pszCmdInput); 1233 1235 return 0; … … 1239 1241 PCDBGCCMD pCmd = dbgcRoutineLookup(pDbgc, pszCmd, pszArgs - pszCmd, fExternal); 1240 1242 if (!pCmd || (pCmd->fFlags & DBGCCMD_FLAGS_FUNCTION)) 1243 { 1244 pDbgc->rcCmd = VINF_PARSE_COMMAND_NOT_FOUND; 1241 1245 return pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "Unknown command '%s'!\n", pszCmdInput); 1246 } 1242 1247 1243 1248 /* 1244 1249 * Parse arguments (if any). 1245 1250 */ 1246 unsigned 1251 unsigned cArgs; 1247 1252 int rc = dbgcProcessArguments(pDbgc, pCmd, pszArgs, &pDbgc->aArgs[pDbgc->iArg], ELEMENTS(pDbgc->aArgs) - pDbgc->iArg, &cArgs); 1248 1253 … … 1252 1257 if (!rc) 1253 1258 { 1254 rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[0], cArgs, NULL); 1259 if (!fNoExecute) 1260 rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[0], cArgs, NULL); 1261 pDbgc->rcCmd = rc; 1255 1262 } 1256 1263 else 1257 1264 { 1265 pDbgc->rcCmd = rc; 1266 1258 1267 /* report parse / eval error. */ 1259 1268 switch (rc) … … 1357 1366 * 1358 1367 * @returns VBox status code. Any error indicates the termination of the console session. 1359 * @param pDbgc Debugger console instance data. 1360 */ 1361 static int dbgcProcessCommands(PDBGC pDbgc) 1368 * @param pDbgc Debugger console instance data. 1369 * @param fNoExecute Indicates that no commands should actually be executed. 1370 */ 1371 static int dbgcProcessCommands(PDBGC pDbgc, bool fNoExecute) 1362 1372 { 1363 1373 int rc = 0; … … 1415 1425 pDbgc->pszScratch = psz; 1416 1426 pDbgc->iArg = 0; 1417 rc = dbgcProcessCommand(pDbgc, &pDbgc->achScratch[0], psz - &pDbgc->achScratch[0] - 1 );1427 rc = dbgcProcessCommand(pDbgc, &pDbgc->achScratch[0], psz - &pDbgc->achScratch[0] - 1, fNoExecute); 1418 1428 if (rc) 1419 1429 break; … … 1575 1585 * 1576 1586 * @returns VBox status. 1577 * @param pDbgc Debugger console instance data. 1578 */ 1579 static int dbgcProcessInput(PDBGC pDbgc) 1587 * @param pDbgc Debugger console instance data. 1588 * @param fNoExecute Indicates that no commands should actually be executed. 1589 */ 1590 int dbgcProcessInput(PDBGC pDbgc, bool fNoExecute) 1580 1591 { 1581 1592 /* … … 1593 1604 /** @todo this fReady stuff is broken. */ 1594 1605 pDbgc->fReady = false; 1595 rc = dbgcProcessCommands(pDbgc );1606 rc = dbgcProcessCommands(pDbgc, fNoExecute); 1596 1607 if (VBOX_SUCCESS(rc) && rc != VWRN_DBGC_CMD_PENDING) 1597 1608 pDbgc->fReady = true; … … 1858 1869 if (pDbgc->pBack->pfnInput(pDbgc->pBack, 0)) 1859 1870 { 1860 rc = dbgcProcessInput(pDbgc );1871 rc = dbgcProcessInput(pDbgc, false /* fNoExecute */); 1861 1872 if (VBOX_FAILURE(rc)) 1862 1873 break; … … 1870 1881 if (pDbgc->pBack->pfnInput(pDbgc->pBack, pDbgc->fLog ? 1 : 1000)) 1871 1882 { 1872 rc = dbgcProcessInput(pDbgc );1883 rc = dbgcProcessInput(pDbgc, false /* fNoExecute */); 1873 1884 if (VBOX_FAILURE(rc)) 1874 1885 break; … … 1939 1950 //pDbgc->iArg = 0; 1940 1951 //pDbgc->rcOutput = 0; 1952 //pDbgc->rcCmd = 0; 1941 1953 1942 1954 dbgcInitOpCharBitMap(); -
trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
r5685 r5686 50 50 /** For keeping track of output prefixing. */ 51 51 static bool g_fPendingPrefix = true; 52 52 /** Pointer to the the current input position. */ 53 const char *g_pszInput = NULL; 53 54 54 55 /** … … 64 65 static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies) 65 66 { 66 RTPrintf("tstDBGCParser: tstDBGCBackInput was called!\n"); 67 g_cErrors++; 68 return false; 67 return g_pszInput != NULL 68 && *g_pszInput != '\0'; 69 69 } 70 70 … … 85 85 static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead) 86 86 { 87 RTPrintf("tstDBGCParser: tstDBGCBackRead was called!\n"); 88 g_cErrors++; 89 return VERR_INTERNAL_ERROR; 87 if (g_pszInput && *g_pszInput) 88 { 89 size_t cb = strlen(g_pszInput); 90 if (cb > cbBuf) 91 cb = cbBuf; 92 *pcbRead = cb; 93 memcpy(pvBuf, g_pszInput, cb); 94 g_pszInput += cb; 95 } 96 else 97 *pcbRead = 0; 98 return VINF_SUCCESS; 90 99 } 91 100 … … 106 115 { 107 116 const char *pch = (const char *)pvBuf; 108 *pcbWritten = cbBuf; 117 if (pcbWritten) 118 *pcbWritten = cbBuf; 109 119 while (cbBuf-- > 0) 110 120 { 111 121 if (g_fPendingPrefix) 112 122 { 113 RTPrintf("tstDBGCParser: OUTPUT: ");123 RTPrintf("tstDBGCParser: OUTPUT: "); 114 124 g_fPendingPrefix = false; 115 125 } … … 135 145 136 146 147 /** 148 * Tries one command string. 149 * @param pDbgc Pointer to the debugger instance. 150 * @param pszCmds The command to test. 151 * @param rcCmd The expected result. 152 */ 153 static void tstTry(PDBGC pDbgc, const char *pszCmds, int rcCmd) 154 { 155 g_pszInput = pszCmds; 156 if (strchr(pszCmds, '\0')[-1] == '\n') 157 RTPrintf("tstDBGCParser: RUNNING: %s", pszCmds); 158 else 159 RTPrintf("tstDBGCParser: RUNNING: %s\n", pszCmds); 160 161 pDbgc->rcCmd = VERR_INTERNAL_ERROR; 162 dbgcProcessInput(pDbgc, true /* fNoExecute */); 163 tstCompleteOutput(); 164 165 if (pDbgc->rcCmd != rcCmd) 166 { 167 RTPrintf("tstDBGCParser: rcCmd=%Rrc expected =%Rrc\n", pDbgc->rcCmd, rcCmd); 168 g_cErrors++; 169 } 170 } 137 171 138 172 … … 152 186 if (RT_SUCCESS(rc)) 153 187 { 188 rc = dbgcProcessInput(pDbgc, true /* fNoExecute */); 189 tstCompleteOutput(); 190 if (RT_SUCCESS(rc)) 191 { 192 tstTry(pDbgc, "stop\n", VINF_SUCCESS); 193 tstTry(pDbgc, "format \n", VERR_PARSE_TOO_FEW_ARGUMENTS); 194 tstTry(pDbgc, "format 0 1 23 4\n", VERR_PARSE_TOO_MANY_ARGUMENTS); 195 tstTry(pDbgc, "sa 3 23 4 'q' \"21123123\" 'b' \n", VINF_SUCCESS); 196 } 154 197 155 198 dbgcDestroy(pDbgc); 156 199 } 157 158 200 159 201 /*
Note:
See TracChangeset
for help on using the changeset viewer.