Changeset 35694 in vbox for trunk/src/VBox/Debugger
- Timestamp:
- Jan 24, 2011 5:35:59 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 69620
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 3 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 -
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r35673 r35694 390 390 static DECLCALLBACK(int) dbgcCmdGo(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult) 391 391 { 392 DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); 393 392 394 /* 393 395 * Check if the VM is halted or not before trying to resume it. 394 396 */ 395 397 if (!DBGFR3IsHalted(pVM)) 396 pCmdHlp->pfnPrintf(pCmdHlp, NULL, "warning: The VM is already running...\n"); 397 else 398 { 399 int rc = DBGFR3Resume(pVM); 400 if (RT_FAILURE(rc)) 401 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Executing DBGFR3Resume()."); 402 } 403 404 NOREF(pCmd); 405 NOREF(paArgs); 406 NOREF(cArgs); 407 NOREF(pResult); 408 return 0; 398 return DBGCCmdHlpFail(pCmdHlp, pCmd, "The VM is already running"); 399 400 int rc = DBGFR3Resume(pVM); 401 if (RT_FAILURE(rc)) 402 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3Resume"); 403 404 NOREF(paArgs); NOREF(cArgs); NOREF(pResult); 405 return VINF_SUCCESS; 409 406 } 410 407 … … 422 419 static DECLCALLBACK(int) dbgcCmdBrkAccess(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/) 423 420 { 421 DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); 422 424 423 /* 425 424 * Interpret access type. … … 427 426 if ( !strchr("xrwi", paArgs[0].u.pszString[0]) 428 427 || paArgs[0].u.pszString[1]) 429 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'.\n",430 428 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access type '%s' for '%s'. Valid types are 'e', 'r', 'w' and 'i'", 429 paArgs[0].u.pszString, pCmd->pszCmd); 431 430 uint8_t fType = 0; 432 431 switch (paArgs[0].u.pszString[0]) … … 442 441 */ 443 442 if (fType == X86_DR7_RW_EO && paArgs[1].u.u64Number != 1) 444 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 'x' access type requires size 1!\n",445 443 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 'x' access type requires size 1!", 444 paArgs[1].u.u64Number, pCmd->pszCmd); 446 445 switch (paArgs[1].u.u64Number) 447 446 { … … 452 451 /*case 8: - later*/ 453 452 default: 454 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid access size %RX64 for '%s'. 1, 2 or 4!\n",455 453 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid access size %RX64 for '%s'. 1, 2 or 4!", 454 paArgs[1].u.u64Number, pCmd->pszCmd); 456 455 } 457 456 uint8_t cb = (uint8_t)paArgs[1].u.u64Number; … … 461 460 */ 462 461 DBGFADDRESS Address; 463 int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address);462 int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[2], &Address); 464 463 if (RT_FAILURE(rc)) 465 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[2], rc);464 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,%DV,)", &paArgs[2]); 466 465 467 466 /* … … 491 490 * Try set the breakpoint. 492 491 */ 493 RTUINTiBp;492 uint32_t iBp; 494 493 rc = DBGFR3BpSetReg(pVM, &Address, iHitTrigger, iHitDisable, fType, cb, &iBp); 495 494 if (RT_SUCCESS(rc)) … … 498 497 rc = dbgcBpAdd(pDbgc, iBp, pszCmds); 499 498 if (RT_SUCCESS(rc)) 500 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);499 return DBGCCmdHlpPrintf(pCmdHlp, "Set access breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 501 500 if (rc == VERR_DBGC_BP_EXISTS) 502 501 { 503 502 rc = dbgcBpUpdate(pDbgc, iBp, pszCmds); 504 503 if (RT_SUCCESS(rc)) 505 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr);504 return DBGCCmdHlpPrintf(pCmdHlp, "Updated access breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 506 505 } 507 506 int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); 508 507 AssertRC(rc2); 509 508 } 510 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set access breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);509 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set access breakpoint at %RGv", Address.FlatPtr); 511 510 } 512 511 … … 524 523 static DECLCALLBACK(int) dbgcCmdBrkClear(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/) 525 524 { 525 DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); 526 526 527 /* 527 528 * Enumerate the arguments. 528 529 */ 529 530 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 530 int rc = VINF_SUCCESS;531 int rc = VINF_SUCCESS; 531 532 for (unsigned iArg = 0; iArg < cArgs && RT_SUCCESS(rc); iArg++) 532 533 { … … 534 535 { 535 536 /* one */ 536 RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;537 if (iBp != paArgs[iArg].u.u64Number)537 uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; 538 if (iBp == paArgs[iArg].u.u64Number) 538 539 { 539 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number); 540 break; 540 int rc2 = DBGFR3BpClear(pVM, iBp); 541 if (RT_FAILURE(rc2)) 542 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp); 543 if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) 544 dbgcBpDelete(pDbgc, iBp); 541 545 } 542 int rc2 = DBGFR3BpClear(pVM, iBp); 543 if (RT_FAILURE(rc2)) 544 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp); 545 if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) 546 dbgcBpDelete(pDbgc, iBp); 546 else 547 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number); 547 548 } 548 549 else if (!strcmp(paArgs[iArg].u.pszString, "all")) … … 552 553 while (pBp) 553 554 { 554 RTUINTiBp = pBp->iBp;555 uint32_t iBp = pBp->iBp; 555 556 pBp = pBp->pNext; 556 557 557 558 int rc2 = DBGFR3BpClear(pVM, iBp); 558 559 if (RT_FAILURE(rc2)) 559 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc2, "DBGFR3BpClear failed for breakpoint %u!\n", iBp);560 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpClear(,%#x)", iBp); 560 561 if (RT_SUCCESS(rc2) || rc2 == VERR_DBGF_BP_NOT_FOUND) 561 562 dbgcBpDelete(pDbgc, iBp); … … 563 564 } 564 565 else 565 { 566 /* invalid parameter */ 567 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd); 568 break; 569 } 566 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString); 570 567 } 571 568 return rc; … … 594 591 { 595 592 /* one */ 596 RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;597 if (iBp != paArgs[iArg].u.u64Number)593 uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; 594 if (iBp == paArgs[iArg].u.u64Number) 598 595 { 599 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number); 600 break; 596 rc = DBGFR3BpDisable(pVM, iBp); 597 if (RT_FAILURE(rc)) 598 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpDisable failed for breakpoint %#x", iBp); 601 599 } 602 rc = DBGFR3BpDisable(pVM, iBp); 603 if (RT_FAILURE(rc)) 604 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", iBp); 600 else 601 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number); 605 602 } 606 603 else if (!strcmp(paArgs[iArg].u.pszString, "all")) … … 610 607 for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext) 611 608 { 612 rc= DBGFR3BpDisable(pVM, pBp->iBp);613 if (RT_FAILURE(rc ))614 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpDisable failed for breakpoint %u!\n", pBp->iBp);609 int rc2 = DBGFR3BpDisable(pVM, pBp->iBp); 610 if (RT_FAILURE(rc2)) 611 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpDisable failed for breakpoint %#x", pBp->iBp); 615 612 } 616 613 } 617 614 else 618 { 619 /* invalid parameter */ 620 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd); 621 break; 622 } 615 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString); 623 616 } 624 617 return rc; … … 638 631 static DECLCALLBACK(int) dbgcCmdBrkEnable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/) 639 632 { 633 DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); 634 640 635 /* 641 636 * Enumerate the arguments. … … 647 642 { 648 643 /* one */ 649 RTUINT iBp = (RTUINT)paArgs[iArg].u.u64Number;650 if (iBp != paArgs[iArg].u.u64Number)644 uint32_t iBp = (uint32_t)paArgs[iArg].u.u64Number; 645 if (iBp == paArgs[iArg].u.u64Number) 651 646 { 652 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Breakpoint id %RX64 is too large!\n", paArgs[iArg].u.u64Number); 653 break; 647 rc = DBGFR3BpEnable(pVM, iBp); 648 if (RT_FAILURE(rc)) 649 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnable failed for breakpoint %#x", iBp); 654 650 } 655 rc = DBGFR3BpEnable(pVM, iBp); 656 if (RT_FAILURE(rc)) 657 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", iBp); 651 else 652 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Breakpoint id %RX64 is too large", paArgs[iArg].u.u64Number); 658 653 } 659 654 else if (!strcmp(paArgs[iArg].u.pszString, "all")) … … 663 658 for (PDBGCBP pBp = pDbgc->pFirstBp; pBp; pBp = pBp->pNext) 664 659 { 665 rc= DBGFR3BpEnable(pVM, pBp->iBp);666 if (RT_FAILURE(rc ))667 rc = pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnable failed for breakpoint %u!\n", pBp->iBp);660 int rc2 = DBGFR3BpEnable(pVM, pBp->iBp); 661 if (RT_FAILURE(rc2)) 662 rc = DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc2, "DBGFR3BpEnable failed for breakpoint %#x", pBp->iBp); 668 663 } 669 664 } 670 665 else 671 { 672 /* invalid parameter */ 673 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Invalid argument '%s' to '%s'!\n", paArgs[iArg].u.pszString, pCmd->pszCmd); 674 break; 675 } 666 rc = DBGCCmdHlpFail(pCmdHlp, pCmd, "Invalid argument '%s'", paArgs[iArg].u.pszString); 676 667 } 677 668 return rc; … … 689 680 static DECLCALLBACK(int) dbgcEnumBreakpointsCallback(PVM pVM, void *pvUser, PCDBGFBP pBp) 690 681 { 691 PDBGC pDbgc= (PDBGC)pvUser;682 PDBGC pDbgc = (PDBGC)pvUser; 692 683 PDBGCBP pDbgcBp = dbgcBpGet(pDbgc, pBp->iBp); 693 684 … … 722 713 } 723 714 724 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%2u%c %d %c %RGv %04RX64 (%04RX64 to ",725 726 715 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%4#x %c %d %c %RGv %04RX64 (%04RX64 to ", 716 pBp->iBp, pBp->fEnabled ? 'e' : 'd', cb, chType, 717 pBp->GCPtr, pBp->cHits, pBp->iHitTrigger); 727 718 if (pBp->iHitDisable == ~(uint64_t)0) 728 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "~0) ");719 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "~0) "); 729 720 else 730 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%04RX64)");721 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%04RX64)"); 731 722 732 723 /* … … 740 731 { 741 732 if (!off) 742 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s", Sym.szName);733 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s", Sym.szName); 743 734 else if (off > 0) 744 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%RGv", Sym.szName, off);735 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, off); 745 736 else 746 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "%s+%RGv", Sym.szName, -off);737 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "%s+%RGv", Sym.szName, -off); 747 738 } 748 739 … … 753 744 { 754 745 if (pDbgcBp->cchCmd) 755 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n cmds: '%s'\n", 756 pDbgcBp->szCmd); 746 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n cmds: '%s'\n", pDbgcBp->szCmd); 757 747 else 758 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, "\n");748 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, "\n"); 759 749 } 760 750 else 761 pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, " [unknown bp]\n");751 DBGCCmdHlpPrintf(&pDbgc->CmdHlp, " [unknown bp]\n"); 762 752 763 753 return VINF_SUCCESS; … … 775 765 * @param cArgs Number of arguments in the array. 776 766 */ 777 static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned /*cArgs*/, PDBGCVAR /*pResult*/) 778 { 767 static DECLCALLBACK(int) dbgcCmdBrkList(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR /*paArgs*/, unsigned cArgs, PDBGCVAR /*pResult*/) 768 { 769 DBGC_CMDHLP_REQ_VM_RET(pCmdHlp, pCmd, pVM); 770 DBGC_CMDHLP_ASSERT_PARSER_RET(pCmdHlp, pCmd, -1, cArgs == 0); 771 772 /* 773 * Enumerate the breakpoints. 774 */ 779 775 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 780 781 /*782 * Enumerate the breakpoints.783 */784 776 int rc = DBGFR3BpEnum(pVM, dbgcEnumBreakpointsCallback, pDbgc); 785 777 if (RT_FAILURE(rc)) 786 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3BpEnum failed.\n");778 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGFR3BpEnum"); 787 779 return rc; 788 780 } … … 799 791 * @param cArgs Number of arguments in the array. 800 792 */ 801 static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)793 static DECLCALLBACK(int) dbgcCmdBrkSet(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/) 802 794 { 803 795 /* … … 805 797 */ 806 798 DBGFADDRESS Address; 807 int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);799 int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address); 808 800 if (RT_FAILURE(rc)) 809 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[0], rc);801 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]); 810 802 811 803 /* … … 835 827 * Try set the breakpoint. 836 828 */ 837 RTUINTiBp;829 uint32_t iBp; 838 830 rc = DBGFR3BpSet(pVM, &Address, iHitTrigger, iHitDisable, &iBp); 839 831 if (RT_SUCCESS(rc)) 840 832 { 841 PDBGC 833 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 842 834 rc = dbgcBpAdd(pDbgc, iBp, pszCmds); 843 835 if (RT_SUCCESS(rc)) 844 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set breakpoint %u at %RGv\n", iBp, Address.FlatPtr);836 return DBGCCmdHlpPrintf(pCmdHlp, "Set breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 845 837 if (rc == VERR_DBGC_BP_EXISTS) 846 838 { 847 839 rc = dbgcBpUpdate(pDbgc, iBp, pszCmds); 848 840 if (RT_SUCCESS(rc)) 849 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr);841 return DBGCCmdHlpPrintf(pCmdHlp, "Updated breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 850 842 } 851 843 int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); 852 844 AssertRC(rc2); 853 845 } 854 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);846 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set breakpoint at %RGv", Address.FlatPtr); 855 847 } 856 848 … … 866 858 * @param cArgs Number of arguments in the array. 867 859 */ 868 static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD /*pCmd*/, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/)860 static DECLCALLBACK(int) dbgcCmdBrkREM(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR /*pResult*/) 869 861 { 870 862 /* … … 872 864 */ 873 865 DBGFADDRESS Address; 874 int rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address);866 int rc = DBGCCmdHlpVarToDbgfAddr(pCmdHlp, &paArgs[0], &Address); 875 867 if (RT_FAILURE(rc)) 876 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Couldn't convert '%DV' to a DBGF address, rc=%Rrc.\n", &paArgs[0], rc);868 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "DBGCCmdHlpVarToDbgfAddr(,'%DV',)", &paArgs[0]); 877 869 878 870 /* … … 902 894 * Try set the breakpoint. 903 895 */ 904 RTUINTiBp;896 uint32_t iBp; 905 897 rc = DBGFR3BpSetREM(pVM, &Address, iHitTrigger, iHitDisable, &iBp); 906 898 if (RT_SUCCESS(rc)) … … 909 901 rc = dbgcBpAdd(pDbgc, iBp, pszCmds); 910 902 if (RT_SUCCESS(rc)) 911 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Set REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);903 return DBGCCmdHlpPrintf(pCmdHlp, "Set REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 912 904 if (rc == VERR_DBGC_BP_EXISTS) 913 905 { 914 906 rc = dbgcBpUpdate(pDbgc, iBp, pszCmds); 915 907 if (RT_SUCCESS(rc)) 916 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr);908 return DBGCCmdHlpPrintf(pCmdHlp, "Updated REM breakpoint %u at %RGv\n", iBp, Address.FlatPtr); 917 909 } 918 910 int rc2 = DBGFR3BpClear(pDbgc->pVM, iBp); 919 911 AssertRC(rc2); 920 912 } 921 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: Failed to set REM breakpoint at %RGv, rc=%Rrc.\n", Address.FlatPtr, rc);913 return DBGCCmdHlpFailRc(pCmdHlp, pCmd, rc, "Failed to set REM breakpoint at %RGv", Address.FlatPtr); 922 914 } 923 915 -
trunk/src/VBox/Debugger/DBGCInternal.h
r35673 r35694 80 80 struct DBGCBP *pNext; 81 81 /** The breakpoint identifier. */ 82 RTUINTiBp;82 uint32_t iBp; 83 83 /** The size of the command. */ 84 84 size_t cchCmd; … … 239 239 /** rc from the last dbgcHlpPrintfV(). */ 240 240 int rcOutput; 241 /** The last character we wrote. */ 242 char chLastOutput; 243 241 244 /** rc from the last command. */ 242 245 int rcCmd;
Note:
See TracChangeset
for help on using the changeset viewer.