From 9b4348b49778ccdf6f22efa812aba9d743944b97 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 4 Aug 2018 20:48:21 +0200 Subject: [PATCH] Handle frame name queries. --- client/TracyProfiler.cpp | 5 ++++- common/TracyQueue.hpp | 2 ++ server/TracyWorker.cpp | 13 +++++++++++++ server/TracyWorker.hpp | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index bf26292f..c68a26cb 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -660,7 +660,7 @@ bool Profiler::SendData( const char* data, size_t len ) void Profiler::SendString( uint64_t str, const char* ptr, QueueType type ) { - assert( type == QueueType::StringData || type == QueueType::ThreadName || type == QueueType::CustomStringData || type == QueueType::PlotName ); + assert( type == QueueType::StringData || type == QueueType::ThreadName || type == QueueType::CustomStringData || type == QueueType::PlotName || type == QueueType::FrameName ); QueueItem item; MemWrite( &item.hdr.type, type ); @@ -806,6 +806,9 @@ bool Profiler::HandleServerQuery() case ServerQueryCallstackFrame: SendCallstackFrame( ptr ); break; + case ServerQueryFrameName: + SendString( ptr, (const char*)ptr, QueueType::FrameName ); + break; default: assert( false ); break; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index b1b053f7..09dfebde 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -47,6 +47,7 @@ enum class QueueType : uint8_t PlotName, SourceLocationPayload, CallstackPayload, + FrameName, NUM_TYPES }; @@ -316,6 +317,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 ), // frame name }; static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" ); diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 0f53e112..93c719ac 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1283,6 +1283,9 @@ void Worker::DispatchProcess( const QueueItem& ev, char*& ptr ) case QueueType::CallstackPayload: AddCallstackPayload( ev.stringTransfer.ptr, ptr, sz ); break; + case QueueType::FrameName: + HandleFrameName( ev.stringTransfer.ptr, ptr, sz ); + break; default: assert( false ); break; @@ -1662,6 +1665,16 @@ void Worker::HandlePlotName( uint64_t name, char* str, size_t sz ) } ); } +void Worker::HandleFrameName( uint64_t name, char* str, size_t sz ) +{ + const auto sl = StoreString( str, sz ); + m_data.frames.StringDiscovered( name, sl, m_data.strings, [this] ( FrameData* dst, FrameData* src ) { + auto sz = dst->frames.size(); + dst->frames.insert( dst->frames.end(), src->frames.begin(), src->frames.end() ); + std::inplace_merge( dst->frames.begin(), dst->frames.begin() + sz, dst->frames.end() ); + } ); +} + void Worker::HandlePostponedPlots() { for( auto& plot : m_data.plots.Data() ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 4846dcda..c34c7c6e 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -324,6 +324,7 @@ private: void InsertPlot( PlotData* plot, int64_t time, double val ); void HandlePlotName( uint64_t name, char* str, size_t sz ); + void HandleFrameName( uint64_t name, char* str, size_t sz ); void HandlePostponedPlots();