diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 8b407611..ccc94d2f 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1324,6 +1324,7 @@ static void FreeAssociatedMemory( const QueueItem& item ) tracy_free( (void*)ptr ); break; case QueueType::Callstack: + case QueueType::CallstackAlloc: ptr = MemRead( &item.callstack.ptr ); tracy_free( (void*)ptr ); break; @@ -1400,6 +1401,11 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) SendCallstackPayload( ptr ); tracy_free( (void*)ptr ); break; + case QueueType::CallstackAlloc: + ptr = MemRead( &item->callstack.ptr ); + SendCallstackAlloc( ptr ); + tracy_free( (void*)ptr ); + break; default: assert( false ); break; @@ -1587,6 +1593,25 @@ void Profiler::SendCallstackPayload( uint64_t _ptr ) } } +void Profiler::SendCallstackAlloc( uint64_t _ptr ) +{ + auto ptr = (const char*)_ptr; + + QueueItem item; + MemWrite( &item.hdr.type, QueueType::CallstackAllocPayload ); + MemWrite( &item.stringTransfer.ptr, _ptr ); + + const auto len = *((uint32_t*)ptr); + assert( len <= std::numeric_limits::max() ); + const auto l16 = uint16_t( len ); + + NeedDataSize( QueueDataSize[(int)QueueType::CallstackAllocPayload] + sizeof( l16 ) + l16 ); + + AppendDataUnsafe( &item, QueueDataSize[(int)QueueType::CallstackAllocPayload] ); + AppendDataUnsafe( &l16, sizeof( l16 ) ); + AppendDataUnsafe( ptr + 4, l16 ); +} + void Profiler::SendCallstackFrame( uint64_t ptr ) { #ifdef TRACY_HAS_CALLSTACK diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 9e2797a5..ac12e00d 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -384,6 +384,7 @@ private: void SendSourceLocation( uint64_t ptr ); void SendSourceLocationPayload( uint64_t ptr ); void SendCallstackPayload( uint64_t ptr ); + void SendCallstackAlloc( uint64_t ptr ); void SendCallstackFrame( uint64_t ptr ); bool HandleServerQuery(); diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 939e715e..8dc010dc 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -56,6 +56,7 @@ enum class QueueType : uint8_t PlotName, SourceLocationPayload, CallstackPayload, + CallstackAllocPayload, FrameName, NUM_TYPES }; @@ -372,6 +373,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // allocated source location payload sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // callstack payload + sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // callstack alloc payload sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // frame name };