Changeset 32239 in vbox for trunk/src/VBox
- Timestamp:
- Sep 3, 2010 5:01:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/DBGFCoreWrite.cpp
r32236 r32239 121 121 ElfHdr.e_shentsize = sizeof(Elf64_Shdr); 122 122 123 int rc = RTFileWrite(hFile, &ElfHdr, sizeof(ElfHdr), NULL /* full write*/);123 int rc = RTFileWrite(hFile, &ElfHdr, sizeof(ElfHdr), NULL /* all */); 124 124 if (RT_SUCCESS(rc) && pcbElfHdr) 125 125 *pcbElfHdr = sizeof(ElfHdr); … … 155 155 ProgHdr.p_paddr = Phys; 156 156 157 int rc = RTFileWrite(hFile, &ProgHdr, sizeof(ProgHdr), NULL /* full write*/);157 int rc = RTFileWrite(hFile, &ProgHdr, sizeof(ProgHdr), NULL /* all */); 158 158 if (RT_SUCCESS(rc) && pcbProgHdr) 159 159 *pcbProgHdr = sizeof(ProgHdr); … … 221 221 * Write note header. 222 222 */ 223 int rc = RTFileWrite(hFile, &ElfNoteHdr, sizeof(ElfNoteHdr), NULL /* full write*/);223 int rc = RTFileWrite(hFile, &ElfNoteHdr, sizeof(ElfNoteHdr), NULL /* all */); 224 224 if (RT_SUCCESS(rc)) 225 225 { … … 227 227 * Write note name. 228 228 */ 229 rc = RTFileWrite(hFile, szNoteName, cbName, NULL /* full write*/);229 rc = RTFileWrite(hFile, szNoteName, cbName, NULL /* all */); 230 230 if (RT_SUCCESS(rc)) 231 231 { … … 241 241 * Write note data. 242 242 */ 243 rc = RTFileWrite(hFile, pcvData, cbData, NULL /* full write*/);243 rc = RTFileWrite(hFile, pcvData, cbData, NULL /* all */); 244 244 if (RT_SUCCESS(rc)) 245 245 { … … 248 248 */ 249 249 if (cbDataAlign > cbData) 250 rc = RTFileWrite(hFile, s_achPad, cbDataAlign - cbData, NULL /* full write*/);250 rc = RTFileWrite(hFile, s_achPad, cbDataAlign - cbData, NULL /* all*/); 251 251 } 252 252 } … … 387 387 if (RT_SUCCESS(rc)) 388 388 { 389 for (uint32_t i = 0; i < pVM->cCpus; i++)389 for (uint32_t iCpu = 0; iCpu < pVM->cCpus; iCpu++) 390 390 { 391 PCPUMCTX pCpuCtx = &pVM->aCpus[i ].cpum.s.Guest;391 PCPUMCTX pCpuCtx = &pVM->aCpus[iCpu].cpum.s.Guest; 392 392 rc = Elf64WriteNoteHdr(hFile, NT_VBOXCPU, s_pcszCoreVBoxCpu, pCpuCtx, sizeof(CPUMCTX), NULL /* pcbNoteHdr */); 393 393 if (RT_FAILURE(rc)) 394 394 { 395 LogRel((DBGFLOG_NAME ":Elf64WriteNoteHdr failed for vCPU[%u] rc=%Rrc\n", i , rc));395 LogRel((DBGFLOG_NAME ":Elf64WriteNoteHdr failed for vCPU[%u] rc=%Rrc\n", iCpu, rc)); 396 396 break; 397 397 } 398 } 399 } 400 401 /* 402 * Write memory ranges. 403 */ 404 if (RT_SUCCESS(rc)) 405 { 406 for (uint16_t iRange = 0; iRange < cMemRanges; iRange++) 407 { 408 RTGCPHYS GCPhysStart; 409 RTGCPHYS GCPhysEnd; 410 bool fIsMmio; 411 rc = PGMR3PhysGetRange(pVM, iRange, &GCPhysStart, &GCPhysEnd, NULL /* pszDesc */, &fIsMmio); 412 if (RT_FAILURE(rc)) 413 { 414 LogRel((DBGFLOG_NAME ":PGMR3PhysGetRange(2) failed for iRange(%u) rc=%Rrc\n", iRange, rc)); 415 break; 416 } 417 418 if (fIsMmio) 419 continue; 420 421 /* 422 * Write page-by-page of this memory range. 423 */ 424 uint64_t cbMemRange = GCPhysEnd - GCPhysStart + 1; 425 uint64_t cbFileRange = fIsMmio ? 0 : cbMemRange; 426 uint64_t cPages = cbMemRange >> PAGE_SHIFT; 427 for (uint64_t iPage = 0; iPage < cPages; iPage++) 428 { 429 const int cbBuf = PAGE_SIZE; 430 void *pvBuf = MMR3HeapAlloc(pVM, MM_TAG_DBGF_CORE_WRITE, cbBuf); 431 if (RT_UNLIKELY(!pvBuf)) 432 { 433 LogRel((DBGFLOG_NAME ":MMR3HeapAlloc failed. iRange=%u iPage=%u\n", iRange, iPage)); 434 break; 435 } 436 437 rc = PGMPhysRead(pVM, GCPhysStart, pvBuf, cbBuf); 438 if (RT_FAILURE(rc)) 439 { 440 /* 441 * For some reason this failed, write out a zero page instead. 442 */ 443 LogRel((DBGFLOG_NAME ":PGMPhysRead failed for iRange=%u iPage=%u. rc=%Rrc. Ignoring...\n", iRange, 444 iPage, rc)); 445 memset(pvBuf, 0, cbBuf); 446 } 447 448 rc = RTFileWrite(hFile, pvBuf, cbBuf, NULL /* all */); 449 if (RT_FAILURE(rc)) 450 { 451 LogRel((DBGFLOG_NAME ":RTFileWrite failed. iRange=%u iPage=%u rc=%Rrc\n", iRange, iPage, rc)); 452 MMR3HeapFree(pvBuf); 453 break; 454 } 455 456 MMR3HeapFree(pvBuf); 457 } 458 459 if (RT_FAILURE(rc)) 460 break; 398 461 } 399 462 }
Note:
See TracChangeset
for help on using the changeset viewer.