1 #ifndef __TRACYCALLSTACK_HPP__
2 #define __TRACYCALLSTACK_HPP__
4 #include "../common/TracyApi.h"
7 #if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5
9 #elif TRACY_HAS_CALLSTACK >= 3
10 # include <execinfo.h>
14 #ifdef TRACY_HAS_CALLSTACK
19 #include "../common/TracyAlloc.hpp"
20 #include "../common/TracyForceInline.hpp"
25 struct CallstackSymbolData
41 struct CallstackEntryData
43 const CallstackEntry*
data;
45 const char* imageName;
48 CallstackSymbolData DecodeSymbolAddress(
uint64_t ptr );
49 CallstackSymbolData DecodeCodeAddress(
uint64_t ptr );
50 const char* DecodeCallstackPtrFast(
uint64_t ptr );
51 CallstackEntryData DecodeCallstackPtr(
uint64_t ptr );
54 #if TRACY_HAS_CALLSTACK == 1
60 assert( depth >= 1 && depth < 63 );
61 return CallTrace( depth );
64 #elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 5
72 static _Unwind_Reason_Code tracy_unwind_callback(
struct _Unwind_Context* ctx,
void* arg )
74 auto state = (BacktraceState*)arg;
78 if( state->current == state->end )
return _URC_END_OF_STACK;
79 *state->current++ = (
void*)pc;
81 return _URC_NO_REASON;
86 assert( depth >= 1 && depth < 63 );
89 BacktraceState state = { (
void**)(trace+1), (
void**)(trace+1+depth) };
90 _Unwind_Backtrace( tracy_unwind_callback, &state );
92 *trace = (
uintptr_t*)state.current - trace + 1;
97 #elif TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
101 assert( depth >= 1 );
104 const auto num = (size_t)backtrace( (
void**)(trace+1), depth );