mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/CrashHandler: Compile WheatyExceptionReport only once and moved its global variable initializer to all projects using it
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -67,9 +67,6 @@ std::stack<SymbolDetail> WheatyExceptionReport::symbolDetails;
|
||||
bool WheatyExceptionReport::alreadyCrashed;
|
||||
std::mutex WheatyExceptionReport::alreadyCrashedLock;
|
||||
WheatyExceptionReport::pRtlGetVersion WheatyExceptionReport::RtlGetVersion;
|
||||
|
||||
// Declare global instance of class
|
||||
WheatyExceptionReport g_WheatyExceptionReport;
|
||||
#pragma warning(pop)
|
||||
|
||||
//============================== Class Methods =============================
|
||||
@@ -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_
|
||||
@@ -434,3 +434,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
|
||||
|
||||
@@ -740,3 +740,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
|
||||
|
||||
@@ -1567,3 +1567,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
|
||||
|
||||
@@ -458,3 +458,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
|
||||
|
||||
@@ -111,3 +111,9 @@ Optional<int> HandleArgs(int argc, char* argv[], std::string* src, std::string*
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
#include "WheatyExceptionReport.h"
|
||||
// must be at end of file because of init_seg pragma
|
||||
INIT_CRASH_HANDLER();
|
||||
#endif
|
||||
|
||||
@@ -604,3 +604,9 @@ int main(int argc, char ** argv)
|
||||
printf("Extract %s. Work complete. No errors.\n", VMAP::VMAP_MAGIC);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user