Changeset 73074 in vbox
- Timestamp:
- Jul 11, 2018 4:20:21 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r72914 r73074 372 372 { "br", 1, 4, &g_aArgBrkREM[0], RT_ELEMENTS(g_aArgBrkREM), 0, dbgcCmdBrkREM, "<address> [passes [max passes]] [cmds]", 373 373 "Sets a recompiler specific breakpoint." }, 374 { "d", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory using last element size." }, 374 { "d", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory using last element size and type." }, 375 { "dF", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as far 16:16." }, 376 { "dFs", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as far 16:16 with near symbols." }, 375 377 { "da", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as ascii string." }, 376 378 { "db", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in bytes." }, 377 379 { "dd", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in double words." }, 380 { "dds", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as double words with near symbols." }, 378 381 { "da", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as ascii string." }, 379 382 { "dg", 0, ~0U, &g_aArgDumpDT[0], RT_ELEMENTS(g_aArgDumpDT), 0, dbgcCmdDumpDT, "[sel [..]]", "Dump the global descriptor table (GDT)." }, … … 391 394 { "dphg", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Guest context." }, 392 395 { "dphh", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Hypervisor context." }, 396 { "dp", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in mode sized words." }, 397 { "dps", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in mode sized words with near symbols." }, 393 398 { "dpt", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the default context." }, 394 399 { "dpta", 1, 1, &g_aArgDumpPTAddr[0],RT_ELEMENTS(g_aArgDumpPTAddr), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps memory at given address as a page table." }, … … 397 402 { "dpth", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the hypervisor." }, 398 403 { "dq", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in quad words." }, 404 { "dqs", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as quad words with near symbols." }, 399 405 { "dt", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the task state segment (TSS)." }, 400 406 { "dt16", 0, 1, &g_aArgDumpTSS[0], RT_ELEMENTS(g_aArgDumpTSS), 0, dbgcCmdDumpTSS, "[tss|tss:ign|addr]", "Dump the 16-bit task state segment (TSS)." }, … … 403 409 { "dti", 1, 2, &g_aArgDumpTypeInfo[0],RT_ELEMENTS(g_aArgDumpTypeInfo), 0, dbgcCmdDumpTypeInfo,"<type> [levels]", "Dump type information." }, 404 410 { "dtv", 2, 3, &g_aArgDumpTypedVal[0],RT_ELEMENTS(g_aArgDumpTypedVal), 0, dbgcCmdDumpTypedVal,"<type> <addr> [levels]", "Dump a memory buffer using the information in the given type." }, 411 { "du", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory as unicode string (little endian)." }, 405 412 { "dw", 0, 1, &g_aArgDumpMem[0], RT_ELEMENTS(g_aArgDumpMem), 0, dbgcCmdDumpMem, "[addr]", "Dump memory in words." }, 406 413 /** @todo add 'e', 'ea str', 'eza str', 'eu str' and 'ezu str'. See also … … 3315 3322 /** 3316 3323 * @callback_method_impl{FNDBGCCMD, 3317 * The 'da'\, 'dq'\, 'dd'\, 'dw' and 'db' commands.} 3324 * The 'da'\, 'dq'\, 'dqs'\, 'dd'\, 'dds'\, 'dw'\, 'db'\, 'dp'\, 'dps'\, 3325 * and 'du' commands.} 3318 3326 */ 3319 3327 static DECLCALLBACK(int) dbgcCmdDumpMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PUVM pUVM, PCDBGCVAR paArgs, unsigned cArgs) … … 3329 3337 DBGC_CMDHLP_REQ_UVM_RET(pCmdHlp, pCmd, pUVM); 3330 3338 3339 #define DBGC_DUMP_MEM_F_ASCII RT_BIT_32(31) 3340 #define DBGC_DUMP_MEM_F_UNICODE RT_BIT_32(30) 3341 #define DBGC_DUMP_MEM_F_FAR RT_BIT_32(29) 3342 #define DBGC_DUMP_MEM_F_SYMBOLS RT_BIT_32(28) 3343 #define DBGC_DUMP_MEM_F_SIZE UINT32_C(0x0000ffff) 3344 3331 3345 /* 3332 3346 * Figure out the element size. 3333 3347 */ 3334 3348 unsigned cbElement; 3335 bool fAscii = false; 3349 bool fAscii = false; 3350 bool fUnicode = false; 3351 bool fFar = false; 3352 bool fSymbols = pCmd->pszCmd[1] && pCmd->pszCmd[2] == 's'; 3336 3353 switch (pCmd->pszCmd[1]) 3337 3354 { … … 3345 3362 fAscii = true; 3346 3363 break; 3364 case 'F': 3365 cbElement = 4; 3366 fFar = true; 3367 break; 3368 case 'p': 3369 cbElement = DBGFR3CpuIsIn64BitCode(pUVM, pDbgc->idCpu) ? 8 : 4; 3370 break; 3371 case 'u': 3372 cbElement = 2; 3373 fUnicode = true; 3374 break; 3347 3375 case '\0': 3348 fAscii = !!(pDbgc->cbDumpElement & 0x80000000); 3349 cbElement = pDbgc->cbDumpElement & 0x7fffffff; 3376 fAscii = RT_BOOL(pDbgc->cbDumpElement & DBGC_DUMP_MEM_F_ASCII); 3377 fSymbols = RT_BOOL(pDbgc->cbDumpElement & DBGC_DUMP_MEM_F_SYMBOLS); 3378 fUnicode = RT_BOOL(pDbgc->cbDumpElement & DBGC_DUMP_MEM_F_UNICODE); 3379 fFar = RT_BOOL(pDbgc->cbDumpElement & DBGC_DUMP_MEM_F_FAR); 3380 cbElement = pDbgc->cbDumpElement & DBGC_DUMP_MEM_F_SIZE; 3350 3381 if (!cbElement) 3351 3382 cbElement = 1; 3352 3383 break; 3353 3384 } 3385 uint32_t const cbDumpElement = cbElement 3386 | (fSymbols ? DBGC_DUMP_MEM_F_SYMBOLS : 0) 3387 | (fFar ? DBGC_DUMP_MEM_F_FAR : 0) 3388 | (fUnicode ? DBGC_DUMP_MEM_F_UNICODE : 0) 3389 | (fAscii ? DBGC_DUMP_MEM_F_ASCII : 0); 3390 pDbgc->cbDumpElement = cbDumpElement; 3354 3391 3355 3392 /* … … 3392 3429 * Do the dumping. 3393 3430 */ 3394 pDbgc->cbDumpElement = cbElement | (fAscii << 31);3395 3431 int cbLeft = (int)pDbgc->DumpPos.u64Range; 3396 uint8_t u 8Prev = '\0';3432 uint8_t u16Prev = '\0'; 3397 3433 for (;;) 3398 3434 { … … 3406 3442 if (RT_FAILURE(rc)) 3407 3443 { 3408 if (u 8Prev && u8Prev != '\n')3444 if (u16Prev && u16Prev != '\n') 3409 3445 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 3410 3446 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "Reading memory at %DV.\n", &pDbgc->DumpPos); … … 3415 3451 */ 3416 3452 memset(&achBuffer[cb], 0, sizeof(achBuffer) - cb); 3417 if (!fAscii )3453 if (!fAscii && !fUnicode) 3418 3454 { 3419 3455 DBGCCmdHlpPrintf(pCmdHlp, "%DV:", &pDbgc->DumpPos); … … 3422 3458 { 3423 3459 const char *pszSpace = " "; 3424 if (cbElement <= 2 && i == 8 && !fAscii)3460 if (cbElement <= 2 && i == 8) 3425 3461 pszSpace = "-"; 3426 3462 switch (cbElement) 3427 3463 { 3428 case 1: DBGCCmdHlpPrintf(pCmdHlp, "%s%02x", pszSpace, *(uint8_t *)&achBuffer[i]); break; 3429 case 2: DBGCCmdHlpPrintf(pCmdHlp, "%s%04x", pszSpace, *(uint16_t *)&achBuffer[i]); break; 3430 case 4: DBGCCmdHlpPrintf(pCmdHlp, "%s%08x", pszSpace, *(uint32_t *)&achBuffer[i]); break; 3431 case 8: DBGCCmdHlpPrintf(pCmdHlp, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); break; 3464 case 1: 3465 DBGCCmdHlpPrintf(pCmdHlp, "%s%02x", pszSpace, *(uint8_t *)&achBuffer[i]); 3466 break; 3467 case 2: 3468 DBGCCmdHlpPrintf(pCmdHlp, "%s%04x", pszSpace, *(uint16_t *)&achBuffer[i]); 3469 break; 3470 case 4: 3471 if (!fFar) 3472 DBGCCmdHlpPrintf(pCmdHlp, "%s%08x", pszSpace, *(uint32_t *)&achBuffer[i]); 3473 else 3474 DBGCCmdHlpPrintf(pCmdHlp, "%s%04x:%04x:", 3475 pszSpace, *(uint16_t *)&achBuffer[i + 2], *(uint16_t *)&achBuffer[i]); 3476 break; 3477 case 8: 3478 DBGCCmdHlpPrintf(pCmdHlp, "%s%016llx", pszSpace, *(uint64_t *)&achBuffer[i]); 3479 break; 3480 } 3481 3482 if (fSymbols) 3483 { 3484 /* Try lookup symbol for the above address. */ 3485 DBGFADDRESS Addr; 3486 int rc = VINF_SUCCESS; 3487 if (cbElement == 8) 3488 DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, *(uint64_t *)&achBuffer[i]); 3489 else if (!fFar) 3490 DBGFR3AddrFromFlat(pDbgc->pUVM, &Addr, *(uint32_t *)&achBuffer[i]); 3491 else 3492 rc = DBGFR3AddrFromSelOff(pDbgc->pUVM, pDbgc->idCpu, &Addr, 3493 *(uint16_t *)&achBuffer[i + 2], *(uint16_t *)&achBuffer[i]); 3494 if (RT_SUCCESS(rc)) 3495 { 3496 RTINTPTR offDisp; 3497 RTDBGSYMBOL Symbol; 3498 rc = DBGFR3AsSymbolByAddr(pUVM, pDbgc->hDbgAs, &Addr, RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL, 3499 &offDisp, &Symbol, NULL); 3500 if (RT_SUCCESS(rc)) 3501 { 3502 if (!offDisp) 3503 rc = DBGCCmdHlpPrintf(pCmdHlp, " %s", Symbol.szName); 3504 else if (offDisp > 0) 3505 rc = DBGCCmdHlpPrintf(pCmdHlp, " %s + %RGv", Symbol.szName, offDisp); 3506 else 3507 rc = DBGCCmdHlpPrintf(pCmdHlp, " %s - %RGv", Symbol.szName, -offDisp); 3508 if (Symbol.cb > 0) 3509 rc = DBGCCmdHlpPrintf(pCmdHlp, " (LB %RGv)", Symbol.cb); 3510 } 3511 } 3512 3513 /* Next line prefix. */ 3514 unsigned iNext = i + cbElement; 3515 if (iNext < cb) 3516 { 3517 DBGCVAR TmpPos = pDbgc->DumpPos; 3518 DBGCCmdHlpEval(pCmdHlp, &TmpPos, "(%Dv) + %x", &pDbgc->DumpPos, iNext); 3519 DBGCCmdHlpPrintf(pCmdHlp, "\n%DV:", &pDbgc->DumpPos); 3520 } 3432 3521 } 3433 3522 } 3434 3523 3435 /* chars column*/3436 if ( pDbgc->cbDumpElement == 1)3524 /* Chars column. */ 3525 if (cbElement == 1) 3437 3526 { 3438 3527 while (i++ < sizeof(achBuffer)) … … 3456 3545 * Only printables + '\t' and '\n' are printed. 3457 3546 */ 3458 if (!u 8Prev)3547 if (!u16Prev) 3459 3548 DBGCCmdHlpPrintf(pCmdHlp, "%DV:\n", &pDbgc->DumpPos); 3460 uint 8_t u8= '\0';3549 uint16_t u16 = '\0'; 3461 3550 unsigned i; 3462 for (i = 0; i < cb; i ++)3551 for (i = 0; i < cb; i += cbElement) 3463 3552 { 3464 u8Prev = u8; 3465 u8 = *(uint8_t *)&achBuffer[i]; 3466 if ( u8 < 127 3467 && ( (RT_C_IS_PRINT(u8) && u8 >= 32) 3468 || u8 == '\t' 3469 || u8 == '\n')) 3470 DBGCCmdHlpPrintf(pCmdHlp, "%c", u8); 3471 else if (!u8) 3553 u16Prev = u16; 3554 if (cbElement == 1) 3555 u16 = *(uint8_t *)&achBuffer[i]; 3556 else 3557 u16 = *(uint16_t *)&achBuffer[i]; 3558 if ( u16 < 127 3559 && ( (RT_C_IS_PRINT(u16) && u16 >= 32) 3560 || u16 == '\t' 3561 || u16 == '\n')) 3562 DBGCCmdHlpPrintf(pCmdHlp, "%c", (int)u16); 3563 else if (!u16) 3472 3564 break; 3473 3565 else 3474 DBGCCmdHlpPrintf(pCmdHlp, "\\x% x", u8);3566 DBGCCmdHlpPrintf(pCmdHlp, "\\x%0*x", cbElement * 2, u16); 3475 3567 } 3476 if (u 8== '\0')3568 if (u16 == '\0') 3477 3569 cb = cbLeft = i + 1; 3478 if (cbLeft - cb <= 0 && u 8Prev != '\n')3570 if (cbLeft - cb <= 0 && u16Prev != '\n') 3479 3571 DBGCCmdHlpPrintf(pCmdHlp, "\n"); 3480 3572 }
Note:
See TracChangeset
for help on using the changeset viewer.