diff options
| -rw-r--r-- | src/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/common/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | src/common/Debugging/Windows/WheatyExceptionReport.cpp (renamed from src/common/Debugging/WheatyExceptionReport.cpp) | 3 | ||||
| -rw-r--r-- | src/common/Debugging/Windows/WheatyExceptionReport.h (renamed from src/common/Debugging/WheatyExceptionReport.h) | 11 | ||||
| -rw-r--r-- | src/server/authserver/Main.cpp | 6 | ||||
| -rw-r--r-- | src/server/worldserver/Main.cpp | 6 | ||||
| -rw-r--r-- | src/tools/map_extractor/System.cpp | 6 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 6 | ||||
| -rw-r--r-- | src/tools/vmap4_assembler/VMapAssembler.cpp | 6 | ||||
| -rw-r--r-- | src/tools/vmap4_extractor/vmapexport.cpp | 6 |
10 files changed, 53 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1d2ea3093f9..f13f506e8e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,8 +10,6 @@ if(WIN32 AND MSVC) set(sources_windows - ${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.cpp - ${CMAKE_SOURCE_DIR}/src/common/Debugging/WheatyExceptionReport.h ${CMAKE_SOURCE_DIR}/src/common/WindowsSettings.manifest ) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 1270519d087..c839bcf54cf 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -12,16 +12,17 @@ CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES # Exclude - ${CMAKE_CURRENT_SOURCE_DIR}/Debugging + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Windows ${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(WIN32) + CollectSourceFiles( + ${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Windows + WINDOWS_DEBUGGING_SOURCES) + list(APPEND PRIVATE_SOURCES + ${WINDOWS_DEBUGGING_SOURCES}) +endif() if(USE_COREPCH) set(PRIVATE_PCH_HEADER PrecompiledHeaders/commonPCH.h) diff --git a/src/common/Debugging/WheatyExceptionReport.cpp b/src/common/Debugging/Windows/WheatyExceptionReport.cpp index 69ade2deab3..a7df9967079 100644 --- a/src/common/Debugging/WheatyExceptionReport.cpp +++ b/src/common/Debugging/Windows/WheatyExceptionReport.cpp @@ -66,9 +66,6 @@ bool WheatyExceptionReport::alreadyCrashed; std::mutex WheatyExceptionReport::alreadyCrashedLock; WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion; -// Declare global instance of class -WheatyExceptionReport g_WheatyExceptionReport; - //============================== Class Methods ============================= WheatyExceptionReport::WheatyExceptionReport() // Constructor diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/Windows/WheatyExceptionReport.h index baca9699c5b..d154fce0d13 100644 --- a/src/common/Debugging/WheatyExceptionReport.h +++ b/src/common/Debugging/Windows/WheatyExceptionReport.h @@ -3,6 +3,7 @@ #define _NO_CVCONST_H +#include "Define.h" #include "Optional.h" #include <windows.h> #include <winnt.h> @@ -322,7 +323,7 @@ struct SymbolDetail bool HasChildren; }; -class WheatyExceptionReport +class TC_COMMON_API WheatyExceptionReport { public: @@ -396,5 +397,11 @@ class WheatyExceptionReport }; -extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class +#define INIT_CRASH_HANDLER() \ + __pragma(warning(push)) \ + __pragma(warning(disable:4073)) /* C4073: initializers put in library initialization area */ \ + __pragma(init_seg(lib)) \ + WheatyExceptionReport g_WheatyExceptionReport; \ + __pragma(warning(pop)) + #endif // _WHEATYEXCEPTIONREPORT_ diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 079f804fe30..fa735217fca 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -379,3 +379,9 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, f return variablesMap; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 87b4363be53..2b05c996ce3 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -749,3 +749,9 @@ variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, f return vm; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index c1830e57253..6252514eaad 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -1147,3 +1147,9 @@ int main(int argc, char * arg[]) return 0; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index cff2007d867..6f3d46d1edb 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -373,3 +373,9 @@ int main(int argc, char** argv) printf("Finished. MMAPS were built in %s\n", secsToTimeString(GetMSTimeDiffToNow(start) / 1000).c_str()); return 0; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif diff --git a/src/tools/vmap4_assembler/VMapAssembler.cpp b/src/tools/vmap4_assembler/VMapAssembler.cpp index 38eb53ed9be..c6d40d1ca44 100644 --- a/src/tools/vmap4_assembler/VMapAssembler.cpp +++ b/src/tools/vmap4_assembler/VMapAssembler.cpp @@ -62,3 +62,9 @@ int main(int argc, char* argv[]) std::cout << "Ok, all done" << std::endl; return 0; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index 5926f2e525c..0c894d17fae 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -366,3 +366,9 @@ int main(int argc, char ** argv) printf("Extract %s. Work complete. No errors.\n", versionString); return 0; } + +#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS +#include "WheatyExceptionReport.h" +// must be at end of file because of init_seg pragma +INIT_CRASH_HANDLER(); +#endif |
