diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 4ddc9de..1aac963 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -67,7 +67,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU) endif() endif() elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC) - set(GENERAL_FLAGS "/MP") + set(GENERAL_FLAGS "/MP /EHa") set(WARNING_FLAGS "/Wall /WX /sdl") set(SECURITY_FLAGS "/GS /guard:cf") set(OPTIMIZATION_FLAGS "/O2 /Oi /Ob2 /Ot /DNDEBUG /GL") diff --git a/src/common.h b/src/common.h index 72d4dfe..45afff2 100644 --- a/src/common.h +++ b/src/common.h @@ -19,7 +19,7 @@ #ifdef _MSC_VER -#pragma warning(disable : 4005 4061 4324 4365 4464 4619 4625 4626 4668 4710 4711 4804 4820 5039 5045 5220 5246 5264) +#pragma warning(disable : 4005 4061 4324 4365 4464 4619 4625 4626 4668 4710 4711 4714 4804 4820 5039 5045 5220 5246 5264) #define FORCEINLINE __forceinline #define NOINLINE __declspec(noinline) #define LIKELY(expression) expression diff --git a/src/log.cpp b/src/log.cpp index f946504..2d2593d 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -51,7 +51,7 @@ static const HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); #pragma comment(lib, "Dbghelp.lib") -LONG WINAPI UnhandledExceptionFilter(_In_ _EXCEPTION_POINTERS*) +LONG WINAPI UnhandledExceptionFilter(_In_ _EXCEPTION_POINTERS* exception_pointers) { constexpr size_t MAX_FRAMES = 32; @@ -70,7 +70,9 @@ LONG WINAPI UnhandledExceptionFilter(_In_ _EXCEPTION_POINTERS*) const HANDLE h = GetCurrentProcess(); - fprintf(stderr, "\n\nUnhandled exception at:\n"); + const uint32_t code = (exception_pointers && exception_pointers->ExceptionRecord) ? exception_pointers->ExceptionRecord->ExceptionCode : 0; + + fprintf(stderr, "\n\nUnhandled exception %X at:\n", code); fflush(stderr); for (size_t j = 0; j < MAX_FRAMES; ++j) { @@ -86,7 +88,7 @@ LONG WINAPI UnhandledExceptionFilter(_In_ _EXCEPTION_POINTERS*) fflush(stderr); // Normal logging might be broken at this point, but try to log it anyway - LOGERR(0, "Unhandled exception at:"); + LOGERR(0, "Unhandled exception " << log::Hex(code) << " at:"); for (size_t j = 0; j < MAX_FRAMES; ++j) { const DWORD64 address = reinterpret_cast(stack_trace[j]);