mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
impr: Only add stacktrace to exceptions thrown in main thread
This commit is contained in:
@@ -7,5 +7,6 @@
|
||||
namespace hex::trace {
|
||||
|
||||
std::optional<StackTraceResult> getLastExceptionStackTrace();
|
||||
void enableExceptionCaptureForCurrentThread();
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace hex::trace {
|
||||
|
||||
static std::optional<StackTraceResult> s_lastExceptionStackTrace;
|
||||
static thread_local bool s_threadExceptionCaptureEnabled = false;
|
||||
|
||||
std::optional<StackTraceResult> getLastExceptionStackTrace() {
|
||||
if (!s_lastExceptionStackTrace.has_value())
|
||||
return std::nullopt;
|
||||
@@ -13,6 +15,10 @@ namespace hex::trace {
|
||||
return result;
|
||||
}
|
||||
|
||||
void enableExceptionCaptureForCurrentThread() {
|
||||
s_threadExceptionCaptureEnabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if defined(HEX_WRAP_CXA_THROW)
|
||||
@@ -21,7 +27,9 @@ namespace hex::trace {
|
||||
|
||||
[[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();
|
||||
if (hex::trace::s_threadExceptionCaptureEnabled)
|
||||
hex::trace::s_lastExceptionStackTrace = hex::trace::getStackTrace();
|
||||
|
||||
__real___cxa_throw(thrownException, type, destructor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user