Added Linux/signal exception handling.

This commit is contained in:
Branimir Karadžić
2025-08-23 09:20:41 -07:00
parent d858859d17
commit d2b8b1aab5
8 changed files with 146 additions and 28 deletions

View File

@@ -9,14 +9,17 @@
#include <bx/file.h>
#include <bx/simd_t.h>
bool testAssertHandler(const bx::Location& _location, const char* _format, va_list _argList)
BX_PRAGMA_DIAGNOSTIC_PUSH();
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4702); // warning C4702: unreachable code
bool testAssertHandler(const bx::Location& _location, uint32_t _skip, const char* _format, va_list _argList)
{
bx::printf("%s(%d): ", _location.filePath, _location.line);
bx::vprintf(_format, _argList);
bx::printf("\n");
uintptr_t stack[32];
const uint32_t num = bx::getCallStack(2 /* skip self */, BX_COUNTOF(stack), stack);
const uint32_t num = bx::getCallStack(2 /* skip self */ + _skip, BX_COUNTOF(stack), stack);
bx::writeCallstack(bx::getStdOut(), stack, num, bx::ErrorIgnore{});
// Throwing exceptions is required for testing asserts being trigged.
@@ -26,6 +29,8 @@ bool testAssertHandler(const bx::Location& _location, const char* _format, va_li
return true;
}
BX_PRAGMA_DIAGNOSTIC_POP();
int runAllTests(int32_t _argc, const char* _argv[])
{
bx::setAssertHandler(testAssertHandler);