[*] fix minidump writing

This commit is contained in:
Reece Wilson 2023-03-31 04:24:19 +01:00
parent 238874cf8c
commit b3ed716e94
2 changed files with 28 additions and 7 deletions

View File

@ -181,8 +181,11 @@ namespace Aurora::Debug
static bool forceFail {false};
_EXCEPTION_POINTERS ptrs;
StackTrace ret;
CONTEXT ctx;
CONTEXT ctx {};
EXCEPTION_RECORD ex {};
ctx.ContextFlags = CONTEXT_ALL;
if (!GetThreadContext(GetCurrentThread(), &ctx))
{
Debug::Panic();
@ -193,8 +196,11 @@ namespace Aurora::Debug
Exit::PostLevel(AuThreads::GetThread(), Aurora::Exit::ETriggerLevel::eFatalException);
}
ptrs.ExceptionRecord = {};
ex.ExceptionCode = 0x1337;
ptrs.ExceptionRecord = &ex;
ptrs.ContextRecord = &ctx;
HandleFatal(fatal, &ptrs);
}

View File

@ -277,10 +277,10 @@ namespace Aurora::Debug
void SaveMinidump(_EXCEPTION_POINTERS *ExceptionInfo, bool isFatal)
{
bool ok {};
MINIDUMP_EXCEPTION_INFORMATION info;
MINIDUMP_EXCEPTION_INFORMATION info {};
info.ThreadId = GetCurrentThreadId();
info.ClientPointers = ExceptionInfo != nullptr;
info.ClientPointers = false;
info.ExceptionPointers = ExceptionInfo;
static const DWORD flags = MiniDumpWithFullMemory |
@ -316,7 +316,7 @@ namespace Aurora::Debug
ok = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, (MINIDUMP_TYPE)flags, &info, nullptr, nullptr);
if (!ok)
{
AuLogWarn("Couldn't write minidump");
AuLogWarn("Couldn't write minidump: {:x}", GetLastError());
goto miniDumpOut;
}
@ -334,6 +334,16 @@ namespace Aurora::Debug
if (isFatal)
{
try
{
Grug::GrugFlushFlushs();
Grug::GrugFlushWrites();
}
catch (...)
{
}
__fastfail('fokd');
}
}
@ -346,13 +356,18 @@ namespace Aurora::Debug
AuString utf8Path;
MINIDUMP_EXCEPTION_INFORMATION info;
if (fatal)
{
AuDebug::AddMemoryCrunch();
}
auto ok = AuIOFS::GetProfileDomain(path); // < could throw inside
if (!ok)
{
path = ".\\";
}
info.ClientPointers = true;
info.ClientPointers = false;
info.ThreadId = GetCurrentThreadId();
info.ExceptionPointers = ExceptionInfo;
@ -388,7 +403,7 @@ namespace Aurora::Debug
ok = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, (MINIDUMP_TYPE)flags, &info, nullptr, nullptr);
if (!ok)
{
AuLogWarn("Couldn't write minidump");
AuLogWarn("Couldn't write minidump: {:x}", GetLastError());
goto miniMiniDumpOut;
}