[*] Harden panics

This commit is contained in:
Reece Wilson 2023-12-29 18:46:16 +00:00
parent 5862dbeacc
commit 7df1d1dd27
2 changed files with 57 additions and 37 deletions

View File

@ -7,20 +7,28 @@
***/
#pragma once
namespace Aurora
{
AUKN_SYM bool RuntimeHasStarted();
}
#if defined(_AUHAS_FMT)
template<typename ... T>
static inline void AU_NORETURN SysPanic(T... args)
{
if constexpr (sizeof...(T) != 0)
if (Aurora::RuntimeHasStarted())
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
}
catch (...)
if constexpr (sizeof...(T) != 0)
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
}
catch (...)
{
}
}
}
Aurora::Debug::Panic();
@ -30,16 +38,19 @@ template<typename ... T>
static inline void AU_NORETURN SysPanic2(AuUInt uLineHintInNonshipBinary,
T... args)
{
if constexpr (sizeof...(T) != 0)
if (Aurora::RuntimeHasStarted())
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
}
catch (...)
if constexpr (sizeof...(T) != 0)
{
Aurora::Debug::AddMemoryCrunch();
try
{
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
}
catch (...)
{
}
}
}
Aurora::Debug::Panic2(uLineHintInNonshipBinary);

View File

@ -11,6 +11,7 @@
//#include <intrin.h>
#include <Source/Grug/AuGrug.hpp>
#include <Source/Console/ConsoleTTY/ConsoleTTY.hpp>
#include <Source/Console/ConsoleStd/ConsoleStd.hpp>
#include <Source/Console/Console.hpp>
namespace Aurora::Debug
@ -54,6 +55,8 @@ namespace Aurora::Debug
AUKN_SYM void Panic()
{
static bool gRunPlatformFastFailOnce {};
//
if (gHandlingFatal)
{
@ -72,38 +75,44 @@ namespace Aurora::Debug
goto failFast;
}
try
{
Console::ConsoleTTY::PumpForce();
}
catch (...)
if (Aurora::RuntimeHasStarted())
{
try
{
Console::ConsoleTTY::PumpForce();
}
catch (...)
{
}
}
try
{
Grug::GrugFlushFlushs();
Grug::GrugFlushWrites();
}
catch (...)
{
try
{
Grug::GrugFlushFlushs();
Grug::GrugFlushWrites();
}
catch (...)
{
}
}
try
{
Console::Pump();
}
catch (...)
{
try
{
Console::Pump();
}
catch (...)
{
}
}
else
{
Console::ConsoleStd::Pump();
gRunPlatformFastFailOnce = true;
}
failFast:
static bool runPlatformFastFailOnce {};
if (!AuExchange(runPlatformFastFailOnce, true))
if (!AuExchange(gRunPlatformFastFailOnce, true))
{
try
{