From ec731787339be55b58f60ae3b4fac004c736cf0c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 5 Mar 2019 02:15:13 +0100 Subject: [PATCH] Move callstack cutting to a separate function. --- client/TracyProfiler.cpp | 27 +++++++++++++++++---------- client/TracyProfiler.hpp | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) 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();