2 #if !defined(_WIN32) && defined(__GLIBC__)
6 #include "exceptiontrace.h"
12 #if defined(WITH_EXCEPTION_TRACE) && !defined(_WIN32) && defined(__GLIBC__)
13 typedef void CxaThrowType(void *, type_info *, void (*)(void *));
14 CxaThrowType *orig_cxa_throw;
21 HookThrow::HookThrow()
23 void *handle = dlopen(0, RTLD_LAZY);
24 orig_cxa_throw = reinterpret_cast<CxaThrowType *>(dlvsym(handle, "__cxa_throw", "CXXABI_1.3"));
31 bool trace_enabled = false;
33 Msp::Debug::Backtrace &get_thread_backtrace()
35 #if __cplusplus>=201103L
36 static thread_local Msp::Debug::Backtrace backtrace;
37 #elif defined(__GNUC__)
38 static __thread Msp::Debug::Backtrace backtrace;
40 static Msp::Debug::Backtrace backtrace;
50 void enable_exception_trace(bool e)
55 const Backtrace &get_exception_trace()
57 return get_thread_backtrace();
63 #if defined(WITH_EXCEPTION_TRACE) && !defined(_WIN32) && defined(__GLIBC__)
64 extern "C" void __cxa_throw(void *exc, std::type_info *type, void (*dest) (void *))
67 get_thread_backtrace() = Msp::Debug::Backtrace::create();
68 orig_cxa_throw(exc, type, dest);