diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index e78294ec..dd5919b9 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -277,6 +277,11 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); tracy_free( (void*)ptr ); break; + case QueueType::ZoneBeginAllocSrcLoc: + ptr = item->zoneBegin.srcloc; + SendSourceLocationPayload( ptr ); + tracy_free( (void*)ptr ); + break; default: break; } @@ -414,10 +419,6 @@ bool Profiler::HandleServerQuery() case ServerQuerySourceLocation: SendSourceLocation( ptr ); break; - case ServerQuerySourceLocationPayload: - SendSourceLocationPayload( ptr ); - tracy_free( (void*)ptr ); - break; case ServerQueryPlotName: SendString( ptr, (const char*)ptr, QueueType::PlotName ); break; diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index 03aa4d82..597596d9 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -22,7 +22,6 @@ enum ServerQuery : uint8_t ServerQueryString, ServerQueryThreadString, ServerQuerySourceLocation, - ServerQuerySourceLocationPayload, ServerQueryPlotName, }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 63549fcc..47a8c41e 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -615,6 +615,9 @@ void View::ProcessZoneBegin( const QueueZoneBegin& ev ) void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) { + auto it = m_pendingSourceLocationPayload.find( ev.srcloc ); + assert( it != m_pendingSourceLocationPayload.end() ); + auto zone = m_slab.AllocInit(); zone->start = ev.time * m_timerMul; @@ -623,13 +626,14 @@ void View::ProcessZoneBeginAllocSrcLoc( const QueueZoneBegin& ev ) assert( ev.cpu == 0xFFFFFFFF || ev.cpu <= std::numeric_limits::max() ); zone->cpu_start = ev.cpu == 0xFFFFFFFF ? -1 : (int8_t)ev.cpu; zone->text = -1; - - CheckSourceLocationPayload( ev.srcloc, zone ); + zone->srcloc = it->second; std::unique_lock lock( m_lock ); NewZone( zone, ev.thread ); lock.unlock(); m_zoneStack[ev.thread].push_back( zone ); + + m_pendingSourceLocationPayload.erase( it ); } void View::ProcessZoneEnd( const QueueZoneEnd& ev ) @@ -854,14 +858,6 @@ void View::CheckSourceLocation( uint64_t ptr ) ServerQuery( ServerQuerySourceLocation, ptr ); } -void View::CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst ) -{ - assert( m_pendingSourceLocationPayload.find( ptr ) == m_pendingSourceLocationPayload.end() ); - m_pendingSourceLocationPayload.emplace( ptr, dst ); - - ServerQuery( ServerQuerySourceLocationPayload, ptr ); -} - void View::AddString( uint64_t ptr, char* str, size_t sz ) { assert( m_strings.find( ptr ) == m_strings.end() ); @@ -932,8 +928,7 @@ void View::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz ) { const auto start = data; - auto pit = m_pendingSourceLocationPayload.find( ptr ); - assert( pit != m_pendingSourceLocationPayload.end() ); + assert( m_pendingSourceLocationPayload.find( ptr ) == m_pendingSourceLocationPayload.end() ); uint32_t color, line; memcpy( &color, data, 4 ); @@ -955,17 +950,14 @@ void View::AddSourceLocationPayload( uint64_t ptr, char* data, size_t sz ) memcpy( slptr, &srcloc, sizeof( srcloc ) ); uint32_t idx = m_sourceLocationPayload.size(); m_sourceLocationPayloadMap.emplace( slptr, idx ); + m_pendingSourceLocationPayload.emplace( ptr, -int32_t( idx + 1 ) ); std::unique_lock lock( m_lock ); m_sourceLocationPayload.push_back( slptr ); - pit->second->srcloc = -int32_t( idx + 1 ); } else { - std::unique_lock lock( m_lock ); - pit->second->srcloc = -int32_t( it->second + 1 ); + m_pendingSourceLocationPayload.emplace( ptr, -int32_t( it->second + 1 ) ); } - - m_pendingSourceLocationPayload.erase( pit ); } uint32_t View::ShrinkSourceLocation( uint64_t srcloc ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index a8a1d025..b8be8265 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -143,7 +143,6 @@ private: void CheckString( uint64_t ptr ); void CheckThreadString( uint64_t id ); void CheckSourceLocation( uint64_t ptr ); - void CheckSourceLocationPayload( uint64_t ptr, ZoneEvent* dst ); void AddString( uint64_t ptr, char* str, size_t sz ); void AddThreadString( uint64_t id, char* str, size_t sz ); @@ -258,7 +257,7 @@ private: std::unordered_map m_plotRev; std::unordered_map m_pendingPlots; std::unordered_map m_sourceLocationShrink; - std::unordered_map m_pendingSourceLocationPayload; + std::unordered_map m_pendingSourceLocationPayload; Slab<64*1024*1024> m_slab;