win: add minidumps to fatal errors
This commit is contained in:
parent
0a5e92ef38
commit
aac3e53941
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
// Change planet name to support the new internal string formatting.
|
// Change planet name to support the new internal string formatting.
|
||||||
"planetNameFormatString" : "- {} -",
|
"planetNameFormatString" : "- {} -",
|
||||||
|
"planetTextOffset" : [0, 120],
|
||||||
"planetTextStyle" : {
|
"planetTextStyle" : {
|
||||||
"backDirectives" : "border=5;fff;fff?border=1;fff;fff7?multiply=000",
|
"backDirectives" : "border=5;fff;fff?border=1;fff;fff7?multiply=000",
|
||||||
"fontSize" : 24
|
"fontSize" : 24
|
||||||
|
@ -4,11 +4,35 @@
|
|||||||
#include "StarLogging.hpp"
|
#include "StarLogging.hpp"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include "minidumpapiset.h"
|
||||||
|
|
||||||
namespace Star {
|
namespace Star {
|
||||||
|
|
||||||
String g_sehMessage;
|
String g_sehMessage;
|
||||||
|
|
||||||
|
static DWORD WINAPI writeMiniDump(void* ExceptionInfo) {
|
||||||
|
auto hFile = CreateFileA("starbound.dmp", GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
|
return 0;
|
||||||
|
MINIDUMP_EXCEPTION_INFORMATION dumpExceptionInfo{};
|
||||||
|
dumpExceptionInfo.ThreadId = GetCurrentThreadId();
|
||||||
|
dumpExceptionInfo.ExceptionPointers = (PEXCEPTION_POINTERS)ExceptionInfo;
|
||||||
|
dumpExceptionInfo.ClientPointers = FALSE;
|
||||||
|
MiniDumpWriteDump(
|
||||||
|
GetCurrentProcess(),
|
||||||
|
GetCurrentProcessId(),
|
||||||
|
hFile,
|
||||||
|
MiniDumpNormal,
|
||||||
|
&dumpExceptionInfo,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
if (dumpExceptionInfo.ExceptionPointers->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
|
||||||
|
MessageBoxA(NULL, "Stack overflow encountered\nA minidump has been generated", NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
struct SignalHandlerImpl {
|
struct SignalHandlerImpl {
|
||||||
bool handlingFatal;
|
bool handlingFatal;
|
||||||
bool handlingInterrupt;
|
bool handlingInterrupt;
|
||||||
@ -98,9 +122,7 @@ struct SignalHandlerImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static LONG CALLBACK vectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) {
|
static LONG CALLBACK vectoredExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW) {
|
auto thread = CreateThread(NULL, 0, writeMiniDump, (void*)ExceptionInfo, 0, NULL);
|
||||||
fatalError("Stack overflow encountered", false);
|
|
||||||
}
|
|
||||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
|
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
|
||||||
handleFatalError("Access violation detected", ExceptionInfo);
|
handleFatalError("Access violation detected", ExceptionInfo);
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
return EXCEPTION_CONTINUE_EXECUTION;
|
||||||
@ -143,7 +165,10 @@ struct SignalHandlerImpl {
|
|||||||
handleFatalError("Error occured", ExceptionInfo);
|
handleFatalError("Error occured", ExceptionInfo);
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
return EXCEPTION_CONTINUE_EXECUTION;
|
||||||
}
|
}
|
||||||
|
if (thread != NULL) {
|
||||||
|
WaitForSingleObject(thread, 10000);
|
||||||
|
CloseHandle(thread);
|
||||||
|
}
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user