diff options
| author | Shauren <shauren.trinity@gmail.com> | 2016-11-28 18:37:51 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2016-11-28 18:37:51 +0100 |
| commit | e0fb4445cd2f5f4bb94ea23122548debddc41ba6 (patch) | |
| tree | a2850cbf86c3097ef99c4bc7cb3255e2b22da63c /src/common | |
| parent | e43529933fbedb02c9e4b636b6e1d9d94398e5e6 (diff) | |
Core/Debugging: Added wheaty everywhere and modified it to always reliably report issues during static initialization
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.cpp | 12 | ||||
| -rw-r--r-- | src/common/Debugging/WheatyExceptionReport.h | 3 |
3 files changed, 13 insertions, 10 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0428738f2dd..231951ed283 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -12,17 +12,9 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES # Exclude - ${CMAKE_CURRENT_SOURCE_DIR}/Debugging ${CMAKE_CURRENT_SOURCE_DIR}/Platform ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders) -# Manually set sources for Debugging directory as we don't want to include WheatyExceptionReport in common project -# It needs to be included both in authserver and worldserver for the static global variable to be properly initialized -# and to handle crash logs on windows -list(APPEND PRIVATE_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Errors.h) - if (USE_COREPCH) set(PRIVATE_PCH_HEADER PrecompiledHeaders/commonPCH.h) set(PRIVATE_PCH_SOURCE PrecompiledHeaders/commonPCH.cpp) diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/WheatyExceptionReport.cpp index 72abec161b9..29d9a35af8a 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/WheatyExceptionReport.cpp @@ -50,8 +50,11 @@ inline LPTSTR ErrorMessage(DWORD dw) //============================== Global Variables ============================= // -// Declare the static variables of the WheatyExceptionReport class +// Declare the static variables of the WheatyExceptionReport class and force their initialization before any other static in the program // +#pragma warning(push) +#pragma warning(disable: 4073) // C4073: initializers put in library initialization area +#pragma init_seg(lib) TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH]; TCHAR WheatyExceptionReport::m_szDumpFileName[MAX_PATH]; LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter; @@ -65,9 +68,9 @@ bool WheatyExceptionReport::alreadyCrashed; std::mutex WheatyExceptionReport::alreadyCrashedLock; WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion; - // Declare global instance of class WheatyExceptionReport g_WheatyExceptionReport; +#pragma warning(pop) //============================== Class Methods ============================= @@ -1460,3 +1463,8 @@ char* WheatyExceptionReport::PrintSymbolDetail(char* pszCurrBuffer) } #endif // _WIN32 + +void InitializeCrashHandler() +{ + // dummy call to make the linker not discard the compilation unit +} diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h index 34919b19e01..de6b6f375e3 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/WheatyExceptionReport.h @@ -210,5 +210,8 @@ class WheatyExceptionReport extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class #endif // _WIN32 + +// dummy call to make the linker not discard the compilation unit +void InitializeCrashHandler(); #endif // _WHEATYEXCEPTIONREPORT_ |
