Changeset 35694 in vbox for trunk/src/VBox/Debugger/DBGCCmdHlp.cpp
- Timestamp:
- Jan 24, 2011 5:35:59 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69620
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCmdHlp.cpp
r35673 r35694 37 37 38 38 /** 39 * Command helper for writing text to the debug console. 40 * 41 * @returns VBox status. 42 * @param pCmdHlp Pointer to the command callback structure. 43 * @param pvBuf What to write. 44 * @param cbBuf Number of bytes to write. 45 * @param pcbWritten Where to store the number of bytes actually written. 46 * If NULL the entire buffer must be successfully written. 47 */ 48 static DECLCALLBACK(int) dbgcHlpWrite(PDBGCCMDHLP pCmdHlp, const void *pvBuf, size_t cbBuf, size_t *pcbWritten) 49 { 50 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 51 return pDbgc->pBack->pfnWrite(pDbgc->pBack, pvBuf, cbBuf, pcbWritten); 52 } 53 54 55 /** 56 * Command helper for writing formatted text to the debug console. 57 * 58 * @returns VBox status. 59 * @param pCmdHlp Pointer to the command callback structure. 60 * @param pcb Where to store the number of bytes written. 61 * @param pszFormat The format string. 62 * This is using the log formatter, so it's format extensions can be used. 63 * @param ... Arguments specified in the format string. 39 * @interface_method_impl{DBGCCMDHLP,pfnPrintf} 64 40 */ 65 41 static DECLCALLBACK(int) dbgcHlpPrintf(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...) … … 77 53 78 54 /** 79 * Callback to format non-standard format specifiers. 55 * Callback to format non-standard format specifiers, employed by dbgcPrintfV 56 * and others. 80 57 * 81 58 * @returns The number of bytes formatted. … … 190 167 191 168 /** 192 * Output callback .169 * Output callback employed by dbgcHlpPrintfV. 193 170 * 194 171 * @returns number of bytes written. … … 199 176 static DECLCALLBACK(size_t) dbgcFormatOutput(void *pvArg, const char *pachChars, size_t cbChars) 200 177 { 201 PDBGC 178 PDBGC pDbgc = (PDBGC)pvArg; 202 179 if (cbChars) 203 180 { 204 181 int rc = pDbgc->pBack->pfnWrite(pDbgc->pBack, pachChars, cbChars, NULL); 205 if (RT_FAILURE(rc)) 182 if (RT_SUCCESS(rc)) 183 pDbgc->chLastOutput = pachChars[cbChars - 1]; 184 else 206 185 { 207 186 pDbgc->rcOutput = rc; … … 216 195 217 196 /** 218 * Command helper for writing formatted text to the debug console. 219 * 220 * @returns VBox status. 221 * @param pCmdHlp Pointer to the command callback structure. 222 * @param pcbWritten Where to store the number of bytes written. 223 * @param pszFormat The format string. 224 * This is using the log formatter, so it's format extensions can be used. 225 * @param args Arguments specified in the format string. 197 * @interface_method_impl{DBGCCMDHLP,pfnPrintfV} 226 198 */ 227 199 static DECLCALLBACK(int) dbgcHlpPrintfV(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args) … … 243 215 244 216 /** 245 * Reports an error from a DBGF call. 246 * 247 * @returns VBox status code appropriate to return from a command. 248 * @param pCmdHlp Pointer to command helpers. 249 * @param rc The VBox status code returned by a DBGF call. 250 * @param pszFormat Format string for additional messages. Can be NULL. 251 * @param ... Format arguments, optional. 217 * @interface_method_impl{DBGCCMDHLP,pfnVBoxErrorV} 252 218 */ 253 219 static DECLCALLBACK(int) dbgcHlpVBoxErrorV(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args) … … 271 237 272 238 /** 273 * Reports an error from a DBGF call. 274 * 275 * @returns VBox status code appropriate to return from a command. 276 * @param pCmdHlp Pointer to command helpers. 277 * @param rc The VBox status code returned by a DBGF call. 278 * @param pszFormat Format string for additional messages. Can be NULL. 279 * @param ... Format arguments, optional. 239 * @interface_method_impl{DBGCCMDHLP,pfnVBoxError} 280 240 */ 281 241 static DECLCALLBACK(int) dbgcHlpVBoxError(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...) … … 290 250 291 251 /** 292 * Command helper for reading memory specified by a DBGC variable. 293 * 294 * @returns VBox status code appropriate to return from a command. 295 * @param pCmdHlp Pointer to the command callback structure. 296 * @param pVM VM handle if GC or physical HC address. 297 * @param pvBuffer Where to store the read data. 298 * @param cbRead Number of bytes to read. 299 * @param pVarPointer DBGC variable specifying where to start reading. 300 * @param pcbRead Where to store the number of bytes actually read. 301 * This optional, but it's useful when read GC virtual memory where a 302 * page in the requested range might not be present. 303 * If not specified not-present failure or end of a HC physical page 304 * will cause failure. 252 * @interface_method_impl{DBGCCMDHLP,pfnMemRead} 305 253 */ 306 254 static DECLCALLBACK(int) dbgcHlpMemRead(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead) … … 472 420 } 473 421 474 /** 475 * Command helper for writing memory specified by a DBGC variable. 476 * 477 * @returns VBox status code appropriate to return from a command. 478 * @param pCmdHlp Pointer to the command callback structure. 479 * @param pVM VM handle if GC or physical HC address. 480 * @param pvBuffer What to write. 481 * @param cbWrite Number of bytes to write. 482 * @param pVarPointer DBGC variable specifying where to start reading. 483 * @param pcbWritten Where to store the number of bytes written. 484 * This is optional. If NULL be aware that some of the buffer 485 * might have been written to the specified address. 422 423 /** 424 * @interface_method_impl{DBGCCMDHLP,pfnMemWrite} 486 425 */ 487 426 static DECLCALLBACK(int) dbgcHlpMemWrite(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten) … … 618 557 619 558 /** 620 * Executes one command expression. 621 * (Hopefully the parser and functions are fully reentrant.) 622 * 623 * @returns VBox status code appropriate to return from a command. 624 * @param pCmdHlp Pointer to the command callback structure. 625 * @param pszExpr The expression. Format string with the format DBGC extensions. 626 * @param ... Format arguments. 559 * @interface_method_impl{DBGCCMDHLP,pfnHlpExec} 627 560 */ 628 561 static DECLCALLBACK(int) dbgcHlpExec(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...) … … 694 627 if (RT_FAILURE(pDbgc->rcOutput)) 695 628 return pDbgc->rcOutput; 629 if (pDbgc->chLastOutput != '\n') 630 dbgcFormatOutput(pDbgc, "\n", 1); 631 return VERR_DBGC_COMMAND_FAILED; 632 } 633 634 635 /** 636 * @copydoc DBGCCMDHLP::pfnFailV 637 */ 638 static DECLCALLBACK(int) dbgcHlpFailRcV(PDBGCCMDHLP pCmdHlp, PCDBGCCMD pCmd, int rc, const char *pszFormat, va_list va) 639 { 640 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 641 642 /* 643 * Do the formatting and output. 644 */ 645 pDbgc->rcOutput = VINF_SUCCESS; 646 RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, "%s: error: ", pCmd->pszCmd); 647 if (RT_FAILURE(pDbgc->rcOutput)) 648 return pDbgc->rcOutput; 649 RTStrFormatV(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, pszFormat, va); 650 if (RT_FAILURE(pDbgc->rcOutput)) 651 return pDbgc->rcOutput; 652 RTStrFormat(dbgcFormatOutput, pDbgc, dbgcStringFormatter, pDbgc, ": %Rrc\n", rc); 653 if (RT_FAILURE(pDbgc->rcOutput)) 654 return pDbgc->rcOutput; 655 696 656 return VERR_DBGC_COMMAND_FAILED; 697 657 } … … 778 738 779 739 /** 780 * Converts a DBGC variable to a number. 781 * 782 * @returns VBox status code. 783 * @param pCmdHlp Pointer to the command callback structure. 784 * @param pVar The variable to convert. 785 * @param pu64Number Where to store the number value. 740 * @interface_method_impl{DBGCCMDHLP,pfnVarToNumber} 786 741 */ 787 742 static DECLCALLBACK(int) dbgcHlpVarToNumber(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, uint64_t *pu64Number) … … 823 778 824 779 /** 825 * Converts a DBGC variable to a boolean. 826 * 827 * @returns VBox status code. 828 * @param pCmdHlp Pointer to the command callback structure. 829 * @param pVar The variable to convert. 830 * @param pf Where to store the boolean. 780 * @interface_method_impl{DBGCCMDHLP,pfnVarToBool} 831 781 */ 832 782 static DECLCALLBACK(int) dbgcHlpVarToBool(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, bool *pf) … … 1255 1205 1256 1206 /** 1257 * Info helper callback wrapper - print formatted string. 1258 * 1259 * @param pHlp Pointer to this structure. 1260 * @param pszFormat The format string. 1261 * @param ... Arguments. 1207 * @interface_method_impl{DBGFINFOHLP,pfnPrintf} 1262 1208 */ 1263 1209 static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...) … … 1272 1218 1273 1219 /** 1274 * Info helper callback wrapper - print formatted string. 1275 * 1276 * @param pHlp Pointer to this structure. 1277 * @param pszFormat The format string. 1278 * @param args Argument list. 1220 * @interface_method_impl{DBGFINFOHLP,pfnPrintfV} 1279 1221 */ 1280 1222 static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args) … … 1310 1252 void dbgcInitCmdHlp(PDBGC pDbgc) 1311 1253 { 1312 pDbgc->CmdHlp. pfnWrite = dbgcHlpWrite;1254 pDbgc->CmdHlp.u32Magic = DBGCCMDHLP_MAGIC; 1313 1255 pDbgc->CmdHlp.pfnPrintfV = dbgcHlpPrintfV; 1314 1256 pDbgc->CmdHlp.pfnPrintf = dbgcHlpPrintf; … … 1320 1262 pDbgc->CmdHlp.pfnExec = dbgcHlpExec; 1321 1263 pDbgc->CmdHlp.pfnFailV = dbgcHlpFailV; 1264 pDbgc->CmdHlp.pfnFailRcV = dbgcHlpFailRcV; 1322 1265 pDbgc->CmdHlp.pfnVarToDbgfAddr = dbgcHlpVarToDbgfAddr; 1323 1266 pDbgc->CmdHlp.pfnVarFromDbgfAddr = dbgcHlpVarFromDbgfAddr; … … 1327 1270 pDbgc->CmdHlp.pfnVarConvert = dbgcHlpVarConvert; 1328 1271 pDbgc->CmdHlp.pfnGetDbgfOutputHlp = dbgcHlpGetDbgfOutputHlp; 1329 } 1330 1272 pDbgc->CmdHlp.u32EndMarker = DBGCCMDHLP_MAGIC; 1273 } 1274
Note:
See TracChangeset
for help on using the changeset viewer.