diff --git a/public/client/TracyCallstack.hpp b/public/client/TracyCallstack.hpp index 0b522b73..36e295a1 100644 --- a/public/client/TracyCallstack.hpp +++ b/public/client/TracyCallstack.hpp @@ -8,9 +8,15 @@ #if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5 # include #elif TRACY_HAS_CALLSTACK >= 3 -# include -#endif + #ifdef USE_LIB_UNWIND_BACKTRACE + // libunwind is in general significantly faster than execinfo based backtraces + #define UNW_LOCAL_ONLY + # include + #else + # include + #endif +#endif #ifndef TRACY_HAS_CALLSTACK @@ -127,7 +133,13 @@ static tracy_force_inline void* Callstack( int depth ) assert( depth >= 1 ); auto trace = (uintptr_t*)tracy_malloc( ( 1 + (size_t)depth ) * sizeof( uintptr_t ) ); + +#ifdef USE_LIB_UNWIND_BACKTRACE + size_t num = unw_backtrace( (void**)(trace+1), depth ); +#else const auto num = (size_t)backtrace( (void**)(trace+1), depth ); +#endif + *trace = num; return trace;