[+] Config: DebugConfig::bIsMemoryErrorFatal

[*] Refactor Aurora::DebugConfig
This commit is contained in:
Reece Wilson 2022-09-12 23:38:44 +01:00
parent 7c167c90f0
commit 9c25b112a3
4 changed files with 36 additions and 21 deletions

View File

@ -266,29 +266,29 @@ namespace Aurora
/**
* @brief Precache/initialize symbols for printable stack traces under binaries not intended for shipping to consumers
*/
bool nonshipPrecachesSymbols {true};
bool bNonshipPrecachesSymbols {true};
/**
* @brief Activates the internal AddVectoredExceptionHandler handler. Might conflict with DRM and other debugging utilities
*/
bool enableWin32RootExceptionHandler {true};
bool bEnableWin32RootExceptionHandler {true};
/**
* @brief
*/
bool enableInjectedExceptionHandler {true};
bool bEnableInjectedExceptionHandler {true};
/**
* @brief Causes a SysPanic
*/
bool isMemoryErrorFatal {false};
bool bIsMemoryErrorFatal {false};
/**
* @brief
*/
bool isExceptionThrowFatal {false};
bool bIsExceptionThrowFatal {false};
bool printExceptionStackTracesOut {true};
bool bPrintExceptionStackTracesOut {true};
};
struct RuntimeStartInfo

View File

@ -181,8 +181,15 @@ namespace Aurora::Debug
void InitNT()
{
if (!gRuntimeConfig.debug.bEnableInjectedExceptionHandler)
{
return;
}
// i dont think we need a slow grug path for windows
// "runs in the same thread context" (- msdn) =/= we will run out of the old threads stack
// cant be any worse than unix &~ ONSTACK traps (ironically on-stack being shorthand for onstack on an alt heap)
SetUnhandledExceptionFilter([](_EXCEPTION_POINTERS *pExceptionInfo) -> LONG
{
try
@ -239,7 +246,7 @@ extern "C" AUKN_SYM void __stdcall _ReportMSVCSEH(void *exception, const void *t
{
auto trace = AuDebug::GetStackTrace();
if (gRuntimeConfig.debug.printExceptionStackTracesOut)
if (gRuntimeConfig.debug.bPrintExceptionStackTracesOut)
{
AuDebug::ReportSEH(handle, exception, throwInfo, {}, trace,
[&](const AuString &str)

View File

@ -217,7 +217,7 @@ namespace Aurora::Debug
// Pre-submit callback -> its showtime
if ((isCritical || isInternal) && (minimal == 0))
{
if (gRuntimeConfig.debug.printExceptionStackTracesOut)
if (gRuntimeConfig.debug.bPrintExceptionStackTracesOut)
{
AuLogWarn("NT Exception: 0x{:x}, {}", ExceptionInfo->ExceptionRecord->ExceptionCode, str);
AuLogWarn("{}", StringifyStackTrace(backtrace));
@ -236,7 +236,7 @@ namespace Aurora::Debug
Telemetry::Mayday();
}
if (isCritical || gRuntimeConfig.debug.isExceptionThrowFatal) // exception = literally anything
if (isCritical || gRuntimeConfig.debug.bIsExceptionThrowFatal) // exception = literally anything
{
PlatformHandleFatal(true);
}
@ -417,8 +417,8 @@ namespace Aurora::Debug
static void DisableWindowsErrorReporting()
{
// Windows has this annoying watchdog that triggers when your main loop doesnt respond after a while
// It's aggressive in its approach, giving the users to forcefully terminate as soon as they spam click a busy app,
// - or never, if the user decides its time for a coffee break the time an app goes grey
// It's aggressive in its approach, giving the users a choice to forcefully terminate as soon as they spam click a busy app,
// or never at all. latterly, its not uncommon for the app to not come back up, bc win32.
// It's too easy to trigger the watchdog and impossible to stop it from deciding the windowed application must die
AuString procName;
if (!Process::GetProcName(procName))
@ -436,7 +436,7 @@ namespace Aurora::Debug
void InitWin32()
{
// ...
if (gRuntimeConfig.debug.nonshipPrecachesSymbols)
if (gRuntimeConfig.debug.bNonshipPrecachesSymbols)
{
CacheInternalBuildSymbols();
}
@ -445,7 +445,7 @@ namespace Aurora::Debug
DisableWindowsErrorReporting();
// ..
if (gRuntimeConfig.debug.enableWin32RootExceptionHandler)
if (gRuntimeConfig.debug.bEnableWin32RootExceptionHandler)
{
AddVectoredExceptionHandler(1, HandleVectorException);
}

View File

@ -21,44 +21,52 @@ namespace Aurora::Memory
return mi_malloc_size(head);
}
#define CHECK_WRAP_RETURN(exp, string) \
auto pRet = exp; \
if (!pRet && gRuntimeConfig.debug.bIsMemoryErrorFatal) \
{ \
SysPanic(string); \
} \
return pRet;
AUKN_SYM void *_ZAlloc(Types::size_t length)
{
return mi_zalloc(length);
CHECK_WRAP_RETURN(mi_zalloc(length), "ZAlloc out of memory");
}
AUKN_SYM void *_ZAlloc(Types::size_t length, Types::size_t align)
{
return mi_zalloc_aligned(length, align);
CHECK_WRAP_RETURN(mi_zalloc_aligned(length, align), "ZAlloc out of memory");
}
AUKN_SYM void *_FAlloc(Types::size_t length)
{
return mi_malloc(length);
CHECK_WRAP_RETURN(mi_malloc(length), "FAlloc out of memory");
}
AUKN_SYM void *_FAlloc(Types::size_t length, Types::size_t align)
{
return mi_malloc_aligned(length, align);
CHECK_WRAP_RETURN(mi_malloc_aligned(length, align), "FAlloc out of memory");
}
AUKN_SYM void *_ZRealloc(void *buffer, Types::size_t length, Types::size_t align)
{
return mi_rezalloc_aligned(buffer, length, align);
CHECK_WRAP_RETURN(mi_rezalloc_aligned(buffer, length, align), "ZAlloc out of memory");
}
AUKN_SYM void *_ZRealloc(void *buffer, Types::size_t length)
{
return mi_rezalloc(buffer, length);
CHECK_WRAP_RETURN(mi_rezalloc(buffer, length), "ZAlloc out of memory");
}
AUKN_SYM void *_FRealloc(void *buffer, Types::size_t length, Types::size_t align)
{
return mi_realloc_aligned(buffer, length, align);
CHECK_WRAP_RETURN(mi_realloc_aligned(buffer, length, align), "MAlloc out of memory");
}
AUKN_SYM void *_FRealloc(void *buffer, Types::size_t length)
{
return mi_realloc(buffer, length);
CHECK_WRAP_RETURN(mi_realloc(buffer, length), "MAlloc out of memory");
}
AUKN_SYM void _Free(void *buffer)