mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add support to use libunwind for backtrace capturing on linux platforms (which is ~ 4x faster than execinfo)
This commit is contained in:
parent
348be05605
commit
4c94b3eff7
@ -8,9 +8,15 @@
|
||||
#if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5
|
||||
# include <unwind.h>
|
||||
#elif TRACY_HAS_CALLSTACK >= 3
|
||||
# include <execinfo.h>
|
||||
#endif
|
||||
#ifdef USE_LIB_UNWIND_BACKTRACE
|
||||
// libunwind is in general significantly faster than execinfo based backtraces
|
||||
#define UNW_LOCAL_ONLY
|
||||
# include <libunwind.h>
|
||||
#else
|
||||
# include <execinfo.h>
|
||||
#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;
|
||||
|
Loading…
Reference in New Issue
Block a user