- Timestamp:
- Nov 17, 2010 9:39:35 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67852
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/DBGFCoreWrite.cpp
r32595 r34134 16 16 */ 17 17 18 /* 19 * VBox VMCore Format: 18 /** @page pg_dbgf_vmcore VMCore Format 19 * 20 * The VirtualBox VMCore Format: 20 21 * [ ELF 64 Header] -- Only 1 21 22 * 22 23 * [ PT_NOTE ] -- Only 1 23 24 * - Offset into CoreDescriptor followed by list of Notes (Note Hdr + data) of VBox CPUs. 24 * - (Any Additional custom Note sections) 25 * - (Any Additional custom Note sections). 25 26 * 26 27 * [ PT_LOAD ] -- One for each contiguous memory chunk 27 * - Memory offset 28 * - File offset 28 * - Memory offset (physical). 29 * - File offset. 29 30 * 30 31 * CoreDescriptor 31 * - Magic, VBox version 32 * - Number of CPus 32 * - Magic, VBox version. 33 * - Number of CPus. 33 34 * 34 35 * Per-CPU register dump 35 * - CPU 1 Note Hdr + Data 36 * - CPU 2 Note Hdr + Data 36 * - CPU 1 Note Hdr + Data. 37 * - CPU 2 Note Hdr + Data. 37 38 * ... 38 39 * (Additional custom notes Hdr+data) 39 * - VBox 1 Note Hdr + Data 40 * - VBox 2 Note Hdr + Data 40 * - VBox 1 Note Hdr + Data. 41 * - VBox 2 Note Hdr + Data. 41 42 * ... 42 43 * Memory dump … … 114 115 ElfHdr.e_version = EV_CURRENT; 115 116 ElfHdr.e_ident[EI_CLASS] = ELFCLASS64; 116 /* 32-bit VMs will produce cores with e_machine EM_386. */117 /* 32-bit builds will produce cores with e_machine EM_386. */ 117 118 #ifdef RT_ARCH_AMD64 118 119 ElfHdr.e_machine = EM_X86_64; … … 149 150 * @return IPRT status code. 150 151 */ 151 static int Elf64WriteProgHdr(RTFILE hFile, uint32_t Type, uint32_t fFlags, uint64_t offFileData, uint64_t cbFileData, uint64_t cbMemData,152 RTGCPHYS Phys, uint64_t *pcbProgHdr)152 static int Elf64WriteProgHdr(RTFILE hFile, uint32_t Type, uint32_t fFlags, uint64_t offFileData, uint64_t cbFileData, 153 uint64_t cbMemData, RTGCPHYS Phys, uint64_t *pcbProgHdr) 153 154 { 154 155 Elf64_Phdr ProgHdr; … … 306 307 307 308 /** 308 * EMT Rendezvous worker function for DBGFR3CoreWrite. 309 * 310 * @param pVM The VM handle. 311 * @param pVCpu The handle of the calling VCPU. 312 * @param pvData Opaque data. 313 * 314 * @return VBox status code. 315 */ 316 static DECLCALLBACK(VBOXSTRICTRC) dbgfR3CoreWrite(PVM pVM, PVMCPU pVCpu, void *pvData) 317 { 318 /* 319 * Validate input. 320 */ 321 AssertReturn(pVM, VERR_INVALID_VM_HANDLE); 322 AssertReturn(pVCpu, VERR_INVALID_VMCPU_HANDLE); 323 AssertReturn(pvData, VERR_INVALID_POINTER); 324 325 PDBGFCOREDATA pDbgfData = (PDBGFCOREDATA)pvData; 326 309 * Worker function for dbgfR3CoreWrite which does the writing. 310 * 311 * @returns VBox status code 312 * @param pVM The VM handle. 313 * @param pDbgfData The core dump parameters. 314 * @param hFile The file to write to. Caller closes this. 315 */ 316 static int dbgfR3CoreWriteWorker(PVM pVM, PDBGFCOREDATA pDbgfData, RTFILE hFile) 317 { 327 318 /* 328 319 * Collect core information. … … 351 342 352 343 /* 353 * Create the core file.354 */355 RTFILE hFile = NIL_RTFILE;356 int rc = RTFileOpen(&hFile, pDbgfData->pszDumpPath, RTFILE_O_CREATE_REPLACE | RTFILE_O_READWRITE);357 if (RT_FAILURE(rc))358 {359 LogRel((DBGFLOG_NAME ": RTFileOpen failed for '%s' rc=%Rrc\n", pDbgfData->pszDumpPath, rc));360 return rc;361 }362 363 /*364 344 * Write ELF header. 365 345 */ … … 367 347 uint64_t cbProgHdr = 0; 368 348 uint64_t offMemRange = 0; 369 rc = Elf64WriteElfHdr(hFile, cProgHdrs, 0 /* cSecHdrs */, &cbElfHdr);349 int rc = Elf64WriteElfHdr(hFile, cProgHdrs, 0 /* cSecHdrs */, &cbElfHdr); 370 350 off += cbElfHdr; 371 351 if (RT_FAILURE(rc)) 372 352 { 373 353 LogRel((DBGFLOG_NAME ": Elf64WriteElfHdr failed. rc=%Rrc\n", rc)); 374 goto CoreWriteDone;354 return rc; 375 355 } 376 356 … … 390 370 { 391 371 LogRel((DBGFLOG_NAME ": Elf64WritreProgHdr failed for PT_NOTE. rc=%Rrc\n", rc)); 392 goto CoreWriteDone;372 return rc; 393 373 } 394 374 … … 396 376 * Write PT_LOAD program header for each memory range. 397 377 */ 398 offMemRange = off + cbNoteSection; 378 offMemRange = off + cbNoteSection; /** @todo this isn't taking the cmemRanges of prog hdrs into account. */ 399 379 for (uint16_t iRange = 0; iRange < cMemRanges; iRange++) 400 380 { … … 407 387 { 408 388 LogRel((DBGFLOG_NAME ": PGMR3PhysGetRange failed for iRange(%u) rc=%Rrc\n", iRange, rc)); 409 goto CoreWriteDone;389 return rc; 410 390 } 411 391 … … 414 394 415 395 Log((DBGFLOG_NAME ": PGMR3PhysGetRange iRange=%u GCPhysStart=%#x GCPhysEnd=%#x cbMemRange=%u\n", 416 396 iRange, GCPhysStart, GCPhysEnd, cbMemRange)); 417 397 418 398 rc = Elf64WriteProgHdr(hFile, PT_LOAD, PF_R, … … 427 407 LogRel((DBGFLOG_NAME ": Elf64WriteProgHdr failed for memory range(%u) cbFileRange=%u cbMemRange=%u rc=%Rrc\n", iRange, 428 408 cbFileRange, cbMemRange, rc)); 429 goto CoreWriteDone;409 return rc; 430 410 } 431 411 … … 441 421 { 442 422 LogRel((DBGFLOG_NAME ": Elf64WriteNoteHdr failed for Note '%s' rc=%Rrc\n", s_pcszCoreVBoxCore, rc)); 443 goto CoreWriteDone;423 return rc; 444 424 } 445 425 … … 454 434 { 455 435 LogRel((DBGFLOG_NAME ": Elf64WriteNoteHdr failed for vCPU[%u] rc=%Rrc\n", iCpu, rc)); 456 goto CoreWriteDone;436 return rc; 457 437 } 458 438 } … … 470 450 { 471 451 LogRel((DBGFLOG_NAME ": PGMR3PhysGetRange(2) failed for iRange(%u) rc=%Rrc\n", iRange, rc)); 472 goto CoreWriteDone;452 return rc; 473 453 } 474 454 … … 488 468 { 489 469 LogRel((DBGFLOG_NAME ": MMR3HeapAlloc failed. iRange=%u iPage=%u\n", iRange, iPage)); 490 goto CoreWriteDone;470 return rc; 491 471 } 492 472 … … 507 487 LogRel((DBGFLOG_NAME ": RTFileWrite failed. iRange=%u iPage=%u rc=%Rrc\n", iRange, iPage, rc)); 508 488 MMR3HeapFree(pvBuf); 509 goto CoreWriteDone;489 return rc; 510 490 } 511 491 … … 514 494 } 515 495 516 CoreWriteDone: 517 RTFileClose(hFile); 518 496 return rc; 497 } 498 499 500 /** 501 * EMT Rendezvous worker function for DBGFR3CoreWrite. 502 * 503 * @param pVM The VM handle. 504 * @param pVCpu The handle of the calling VCPU. 505 * @param pvData Opaque data. 506 * 507 * @return VBox status code. 508 */ 509 static DECLCALLBACK(VBOXSTRICTRC) dbgfR3CoreWrite(PVM pVM, PVMCPU pVCpu, void *pvData) 510 { 511 /* 512 * Validate input. 513 */ 514 AssertReturn(pVM, VERR_INVALID_VM_HANDLE); 515 AssertReturn(pVCpu, VERR_INVALID_VMCPU_HANDLE); 516 AssertReturn(pvData, VERR_INVALID_POINTER); 517 518 PDBGFCOREDATA pDbgfData = (PDBGFCOREDATA)pvData; 519 520 /* 521 * Create the core file. 522 */ 523 RTFILE hFile; 524 int rc = RTFileOpen(&hFile, pDbgfData->pszDumpPath, RTFILE_O_CREATE_REPLACE | RTFILE_O_READWRITE); 525 if (RT_SUCCESS(rc)) 526 { 527 rc = dbgfR3CoreWriteWorker(pVM, pDbgfData, hFile); 528 RTFileClose(hFile); 529 } 530 else 531 LogRel((DBGFLOG_NAME ": RTFileOpen failed for '%s' rc=%Rrc\n", pDbgfData->pszDumpPath, rc)); 519 532 return rc; 520 533 }
Note:
See TracChangeset
for help on using the changeset viewer.