Reece
4dddcb108e
[*] Dont fail on non-blocking /dev/urand [+] Added if not initialized check under RNG/unix fclose [+] Add missing debug apis ready for report to linux [*] Update build script for WIP branch
96 lines
2.4 KiB
C++
96 lines
2.4 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: Panic.cpp
|
|
Date: 2021-6-12
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "Debug.hpp"
|
|
#include "Panic.hpp"
|
|
//#include <intrin.h>
|
|
#include <Source/Console/ConsoleFIO/ConsoleFIO.hpp>
|
|
|
|
namespace Aurora::Debug
|
|
{
|
|
AUKN_SYM void DebugBreak()
|
|
{
|
|
#if defined(DEBUG) || defined(STAGING)
|
|
#if defined(AURORA_PLATFORM_WIN32)
|
|
#if defined(STAGING)
|
|
if (IsDebuggerPresent())
|
|
#endif
|
|
{
|
|
::DebugBreak();
|
|
}
|
|
#elif defined(DEBUG)
|
|
#if defined(AURORA_COMPILER_MSVC)
|
|
__debugbreak();
|
|
#elif (defined(__has_builtin) && __has_builtin(__builtin_debugtrap))
|
|
__builtin_debugtrap();
|
|
#elif defined(AURORA_COMPILER_GCC) || defined(AURORA_COMPILER_CLANG)
|
|
// GCC is a terrible compiler, msvc is annoying at best, and LLVM + cpp frontend seems great, whats new?
|
|
// I refuse to chuck inline assembly here, not here, not in this project, not for freetards.
|
|
#endif
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
AUKN_SYM void Panic()
|
|
{
|
|
DebugBreak();
|
|
|
|
try
|
|
{
|
|
CheckErrors();
|
|
}
|
|
catch (...)
|
|
{
|
|
|
|
}
|
|
|
|
try
|
|
{
|
|
Console::ConsoleFIO::Flush();
|
|
}
|
|
catch (...)
|
|
{
|
|
|
|
}
|
|
|
|
static bool panicSingleshot = false;
|
|
if (std::exchange(panicSingleshot, true))
|
|
{
|
|
try
|
|
{
|
|
Telemetry::Mayday();
|
|
}
|
|
catch (...)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
//
|
|
static bool handlingFatal = false;
|
|
if (std::exchange(handlingFatal, true))
|
|
{
|
|
std::terminate();
|
|
}
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
// there is a syscall you can use to terminate in instances like this
|
|
// anticheats and drm love it
|
|
// i just dont remember what it is
|
|
// amendment: i believe its some software interrupt that raises an unhandleable exception
|
|
TerminateProcess(GetCurrentProcess(), 0xDEAD);
|
|
#else
|
|
#if defined(AURORA_COMPILER_GCC) || defined(AURORA_COMPILER_CLANG)
|
|
__builtin_trap();
|
|
#else
|
|
std::terminate();
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|