diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llwindebug.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/linden/indra/newview/llwindebug.cpp b/linden/indra/newview/llwindebug.cpp index d2f6748..04457eb 100644 --- a/linden/indra/newview/llwindebug.cpp +++ b/linden/indra/newview/llwindebug.cpp | |||
@@ -42,6 +42,7 @@ | |||
42 | #pragma warning(disable: 4200) //nonstandard extension used : zero-sized array in struct/union | 42 | #pragma warning(disable: 4200) //nonstandard extension used : zero-sized array in struct/union |
43 | #pragma warning(disable: 4100) //unreferenced formal parameter | 43 | #pragma warning(disable: 4100) //unreferenced formal parameter |
44 | 44 | ||
45 | |||
45 | /* | 46 | /* |
46 | LLSD Block for Windows Dump Information | 47 | LLSD Block for Windows Dump Information |
47 | <llsd> | 48 | <llsd> |
@@ -552,6 +553,58 @@ void LLMemoryReserve::release() | |||
552 | 553 | ||
553 | static LLMemoryReserve gEmergencyMemoryReserve; | 554 | static LLMemoryReserve gEmergencyMemoryReserve; |
554 | 555 | ||
556 | #ifndef _M_IX86 | ||
557 | #error "The following code only works for x86!" | ||
558 | #endif | ||
559 | LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter( | ||
560 | LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter) | ||
561 | { | ||
562 | if(lpTopLevelExceptionFilter == gFilterFunc) | ||
563 | return gFilterFunc; | ||
564 | |||
565 | llinfos << "Someone tried to set the exception filter. Listing call stack modules" << llendl; | ||
566 | LLSD cs_info; | ||
567 | GetCallStackData(NULL, cs_info); | ||
568 | |||
569 | if(cs_info.has("CallStack") && cs_info["CallStack"].isArray()) | ||
570 | { | ||
571 | LLSD cs = cs_info["CallStack"]; | ||
572 | for(LLSD::array_iterator i = cs.beginArray(); | ||
573 | i != cs.endArray(); | ||
574 | ++i) | ||
575 | { | ||
576 | llinfos << "Module: " << (*i)["ModuleName"] << llendl; | ||
577 | } | ||
578 | } | ||
579 | |||
580 | return gFilterFunc; | ||
581 | } | ||
582 | |||
583 | BOOL PreventSetUnhandledExceptionFilter() | ||
584 | { | ||
585 | HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll")); | ||
586 | if (hKernel32 == NULL) | ||
587 | return FALSE; | ||
588 | |||
589 | void *pOrgEntry = GetProcAddress(hKernel32, "SetUnhandledExceptionFilter"); | ||
590 | if(pOrgEntry == NULL) | ||
591 | return FALSE; | ||
592 | |||
593 | unsigned char newJump[ 100 ]; | ||
594 | DWORD dwOrgEntryAddr = (DWORD)pOrgEntry; | ||
595 | dwOrgEntryAddr += 5; // add 5 for 5 op-codes for jmp far | ||
596 | void *pNewFunc = &MyDummySetUnhandledExceptionFilter; | ||
597 | DWORD dwNewEntryAddr = (DWORD) pNewFunc; | ||
598 | DWORD dwRelativeAddr = dwNewEntryAddr - dwOrgEntryAddr; | ||
599 | |||
600 | newJump[ 0 ] = 0xE9; // JMP absolute | ||
601 | memcpy(&newJump[ 1 ], &dwRelativeAddr, sizeof(pNewFunc)); | ||
602 | SIZE_T bytesWritten; | ||
603 | BOOL bRet = WriteProcessMemory(GetCurrentProcess(), | ||
604 | pOrgEntry, newJump, sizeof(pNewFunc) + 1, &bytesWritten); | ||
605 | return bRet; | ||
606 | } | ||
607 | |||
555 | // static | 608 | // static |
556 | void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) | 609 | void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) |
557 | { | 610 | { |
@@ -602,6 +655,9 @@ void LLWinDebug::initExceptionHandler(LPTOP_LEVEL_EXCEPTION_FILTER filter_func) | |||
602 | LPTOP_LEVEL_EXCEPTION_FILTER prev_filter; | 655 | LPTOP_LEVEL_EXCEPTION_FILTER prev_filter; |
603 | prev_filter = SetUnhandledExceptionFilter(filter_func); | 656 | prev_filter = SetUnhandledExceptionFilter(filter_func); |
604 | 657 | ||
658 | // *REMOVE:Mani | ||
659 | //PreventSetUnhandledExceptionFilter(); | ||
660 | |||
605 | if(prev_filter != gFilterFunc) | 661 | if(prev_filter != gFilterFunc) |
606 | { | 662 | { |
607 | LL_WARNS("AppInit") | 663 | LL_WARNS("AppInit") |
@@ -737,3 +793,10 @@ void LLWinDebug::generateCrashStacks(struct _EXCEPTION_POINTERS *exception_infop | |||
737 | LLSDSerialize::toPrettyXML(info, out_file); | 793 | LLSDSerialize::toPrettyXML(info, out_file); |
738 | out_file.close(); | 794 | out_file.close(); |
739 | } | 795 | } |
796 | |||
797 | void LLWinDebug::clearCrashStacks() | ||
798 | { | ||
799 | LLSD info; | ||
800 | std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLifeException.log"); | ||
801 | LLFile::remove(dump_path); | ||
802 | } | ||