feat: Add full exception tracing support

This commit is contained in:
WerWolv
2025-05-26 20:15:20 +02:00
parent f341413248
commit ce74915c14
14 changed files with 194 additions and 52 deletions

View File

@@ -0,0 +1,27 @@
#include <hex/trace/exceptions.hpp>
namespace hex::trace {
static std::optional<StackTraceResult> s_lastExceptionStackTrace;
std::optional<StackTraceResult> getLastExceptionStackTrace() {
if (!s_lastExceptionStackTrace.has_value())
return std::nullopt;
auto result = s_lastExceptionStackTrace.value();
s_lastExceptionStackTrace.reset();
return result;
}
}
extern "C" {
[[noreturn]] void __real___cxa_throw(void* thrownException, void* type, void (*destructor)(void*));
[[noreturn]] void __wrap___cxa_throw(void* thrownException, void* type, void (*destructor)(void*)) {
hex::trace::s_lastExceptionStackTrace = hex::trace::getStackTrace();
__real___cxa_throw(thrownException, type, destructor);
}
}