diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 5128cc67..4456fcd2 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1862,7 +1862,23 @@ void Profiler::SendCallstack( int depth, uint64_t thread, const char* skipBefore { #ifdef TRACY_HAS_CALLSTACK auto ptr = Callstack( depth ); - auto data = (uintptr_t*)ptr; + CutCallstack( ptr, skipBefore ); + + Magic magic; + auto token = GetToken(); + auto& tail = token->get_tail_index(); + auto item = token->enqueue_begin( magic ); + MemWrite( &item->hdr.type, QueueType::Callstack ); + MemWrite( &item->callstack.ptr, ptr ); + MemWrite( &item->callstack.thread, thread ); + tail.store( magic + 1, std::memory_order_release ); +#endif +} + +void Profiler::CutCallstack( void* callstack, const char* skipBefore ) +{ +#ifdef TRACY_HAS_CALLSTACK + auto data = (uintptr_t*)callstack; const auto sz = *data++; uintptr_t i; for( i=0; iget_tail_index(); - auto item = token->enqueue_begin( magic ); - MemWrite( &item->hdr.type, QueueType::Callstack ); - MemWrite( &item->callstack.ptr, ptr ); - MemWrite( &item->callstack.thread, thread ); - tail.store( magic + 1, std::memory_order_release ); #endif } diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index ac12e00d..a5b592f1 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -339,6 +339,7 @@ public: } void SendCallstack( int depth, uint64_t thread, const char* skipBefore ); + static void CutCallstack( void* callstack, const char* skipBefore ); static bool ShouldExit();