Changeset 68980 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Oct 4, 2017 12:35:20 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/init-win.cpp
r68976 r68980 30 30 *********************************************************************************************************************************/ 31 31 #define LOG_GROUP RTLOGGROUP_DEFAULT 32 #include <iprt/ win/windows.h>32 #include <iprt/nt/nt-and-windows.h> 33 33 #ifndef LOAD_LIBRARY_SEARCH_APPLICATION_DIR 34 34 # define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x200 … … 400 400 if (pLogger) 401 401 { 402 RTLogLogger(pLogger, NULL, "\nrtR3WinUnhandledXcptFilter: !Exception!\n"); 403 RTLogLogger(pLogger, NULL, "Thread ID: %p\n", RTThreadNativeSelf()); 402 RTLogLogger(pLogger, NULL, "\n!!! rtR3WinUnhandledXcptFilter caught an exception on thread %p!!!\n", RTThreadNativeSelf()); 404 403 405 404 /* 406 405 * Dump the exception record. 407 406 */ 407 uintptr_t uXcptPC = 0; 408 408 PEXCEPTION_RECORD pXcptRec = RT_VALID_PTR(pPtrs) && RT_VALID_PTR(pPtrs->ExceptionRecord) ? pPtrs->ExceptionRecord : NULL; 409 409 if (pXcptRec) 410 410 { 411 RTLogLogger(pLogger, NULL, " ExceptionCode=%#010x ExceptionFlags=%#010x ExceptionAddress=%p\n",411 RTLogLogger(pLogger, NULL, "\nExceptionCode=%#010x ExceptionFlags=%#010x ExceptionAddress=%p\n", 412 412 pXcptRec->ExceptionCode, pXcptRec->ExceptionFlags, pXcptRec->ExceptionAddress); 413 413 for (uint32_t i = 0; i < RT_MIN(pXcptRec->NumberParameters, EXCEPTION_MAXIMUM_PARAMETERS); i++) 414 414 RTLogLogger(pLogger, NULL, "ExceptionInformation[%d]=%p\n", i, pXcptRec->ExceptionInformation[i]); 415 uXcptPC = (uintptr_t)pXcptRec->ExceptionAddress; 415 416 416 417 /* Nested? Display one level only. */ … … 423 424 for (uint32_t i = 0; i < RT_MIN(pNestedRec->NumberParameters, EXCEPTION_MAXIMUM_PARAMETERS); i++) 424 425 RTLogLogger(pLogger, NULL, "Nested: ExceptionInformation[%d]=%p\n", i, pNestedRec->ExceptionInformation[i]); 426 uXcptPC = (uintptr_t)pNestedRec->ExceptionAddress; 425 427 } 426 428 } … … 435 437 { 436 438 #ifdef RT_ARCH_AMD64 437 RTLogLogger(pLogger, NULL, " cs:rip=%04x:%016RX64\n", pXcptCtx->SegCs, pXcptCtx->Rip);439 RTLogLogger(pLogger, NULL, "\ncs:rip=%04x:%016RX64\n", pXcptCtx->SegCs, pXcptCtx->Rip); 438 440 RTLogLogger(pLogger, NULL, "ss:rsp=%04x:%016RX64 rbp=%016RX64\n", pXcptCtx->SegSs, pXcptCtx->Rsp, pXcptCtx->Rbp); 439 441 RTLogLogger(pLogger, NULL, "rax=%016RX64 rcx=%016RX64 rdx=%016RX64 rbx=%016RX64\n", … … 456 458 pXcptCtx->LastExceptionToRip, pXcptCtx->LastExceptionFromRip); 457 459 uXcptSP = pXcptCtx->Rsp; 460 uXcptPC = pXcptCtx->Rip; 458 461 459 462 #elif defined(RT_ARCH_X86) 460 RTLogLogger(pLogger, NULL, " cs:eip=%04x:%08RX32\n", pXcptCtx->SegCs, pXcptCtx->Eip);463 RTLogLogger(pLogger, NULL, "\ncs:eip=%04x:%08RX32\n", pXcptCtx->SegCs, pXcptCtx->Eip); 461 464 RTLogLogger(pLogger, NULL, "ss:esp=%04x:%08RX32 ebp=%08RX32\n", pXcptCtx->SegSs, pXcptCtx->Esp, pXcptCtx->Ebp); 462 465 RTLogLogger(pLogger, NULL, "eax=%08RX32 ecx=%08RX32 edx=%08RX32 ebx=%08RX32\n", … … 467 470 pXcptCtx->SegDs, pXcptCtx->SegEs, pXcptCtx->SegFs, pXcptCtx->SegGs, pXcptCtx->EFlags); 468 471 uXcptSP = pXcptCtx->Esp; 472 uXcptPC = pXcptCtx->Eip; 469 473 #endif 470 474 } … … 473 477 * Dump stack. 474 478 */ 475 void *pvStack = (void *)&szMarker[0]; 476 size_t cbToDump = PAGE_SIZE - ((uintptr_t)pvStack & PAGE_OFFSET_MASK); 479 uintptr_t uStack = (uintptr_t)(void *)&szMarker[0]; 480 uStack -= uStack & 15; 481 482 size_t cbToDump = PAGE_SIZE - (uStack & PAGE_OFFSET_MASK); 477 483 if (cbToDump < 512) 478 484 cbToDump += PAGE_SIZE; 479 size_t cbToXcpt = uXcptSP - (uintptr_t)pvStack;485 size_t cbToXcpt = uXcptSP - uStack; 480 486 while (cbToXcpt > cbToDump && cbToXcpt <= _16K) 481 487 cbToDump += PAGE_SIZE; … … 485 491 { 486 492 g_pfnGetCurrentThreadStackLimits(&uLow, &uHigh); 487 size_t cbToTop = RT_MAX(uLow, uHigh) - (uintptr_t)pvStack;493 size_t cbToTop = RT_MAX(uLow, uHigh) - uStack; 488 494 if (cbToTop < _1M) 489 495 cbToDump = cbToTop; 490 496 } 491 497 492 RTLogLogger(pLogger, NULL, "\nStack %p, dumping %#x bytes (low=%p, high=%p)\n", pvStack, cbToDump, uLow, uHigh);493 RTLogLogger(pLogger, NULL, "%.*Rhxd\n", cbToDump, pvStack);498 RTLogLogger(pLogger, NULL, "\nStack %p, dumping %#x bytes (low=%p, high=%p)\n", uStack, cbToDump, uLow, uHigh); 499 RTLogLogger(pLogger, NULL, "%.*Rhxd\n", cbToDump, uStack); 494 500 495 501 /* … … 502 508 RTLogLogger(pLogger, NULL, "Thread name: %s\n", RTThreadSelfName()); 503 509 RTLogLogger(pLogger, NULL, "Thread IPRT: %p\n", RTThreadSelf()); 510 511 /* 512 * Try dump the load information. 513 */ 514 PPEB pPeb = RTNtCurrentPeb(); 515 if (RT_VALID_PTR(pPeb)) 516 { 517 PPEB_LDR_DATA pLdrData = pPeb->Ldr; 518 if (RT_VALID_PTR(pLdrData)) 519 { 520 LIST_ENTRY *pList = &pLdrData->InMemoryOrderModuleList; 521 LIST_ENTRY *pListEntry = pList->Flink; 522 uint32_t cLoops = 0; 523 RTLogLogger(pLogger, NULL, 524 "\nLoaded Modules:\n" 525 "%-*s[*] Timestamp Path\n", sizeof(void *) * 4 + 2 - 1, "Address range" 526 ); 527 while (pListEntry != pList && RT_VALID_PTR(pListEntry) && cLoops < 1024) 528 { 529 PLDR_DATA_TABLE_ENTRY pLdrEntry = RT_FROM_MEMBER(pListEntry, LDR_DATA_TABLE_ENTRY, InMemoryOrderLinks); 530 uint32_t const cbLength = (uint32_t)(uintptr_t)pLdrEntry->Reserved3[1]; 531 char const chInd = uXcptPC - (uintptr_t)pLdrEntry->DllBase < cbLength ? '*' : ' '; 532 533 if ( RT_VALID_PTR(pLdrEntry->FullDllName.Buffer) 534 && pLdrEntry->FullDllName.Length > 0 535 && pLdrEntry->FullDllName.Length < _8K 536 && (pLdrEntry->FullDllName.Length & 1) == 0 537 && pLdrEntry->FullDllName.Length <= pLdrEntry->FullDllName.MaximumLength) 538 RTLogLogger(pLogger, NULL, "%p..%p%c %08RX32 %.*ls\n", 539 pLdrEntry->DllBase, (uintptr_t)pLdrEntry->DllBase + cbLength - 1, chInd, 540 pLdrEntry->TimeDateStamp, pLdrEntry->FullDllName.Length / sizeof(RTUTF16), 541 pLdrEntry->FullDllName.Buffer); 542 else 543 RTLogLogger(pLogger, NULL, "%p..%p%c %08RX32 <bad or missing: %p LB %#x max %#x\n", 544 pLdrEntry->DllBase, (uintptr_t)pLdrEntry->DllBase + cbLength - 1, chInd, 545 pLdrEntry->TimeDateStamp, pLdrEntry->FullDllName.Buffer, pLdrEntry->FullDllName.Length, 546 pLdrEntry->FullDllName.MaximumLength); 547 548 /* advance */ 549 pListEntry = pListEntry->Flink; 550 cLoops++; 551 } 552 } 553 } 504 554 } 505 555
Note:
See TracChangeset
for help on using the changeset viewer.