From 110e5971d152f5174252f9b9f9a643b457c14f75 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 4 Oct 2017 18:32:22 +0200 Subject: [PATCH] Store pending lock events, if lock was not yet announced. --- server/TracyView.cpp | 36 ++++++++++++++++++++++++++++++++++++ server/TracyView.hpp | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 51d3cf55..5e246293 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -377,10 +377,13 @@ void View::Process( const QueueItem& ev ) ProcessLockAnnounce( ev.lockAnnounce ); break; case QueueType::LockWait: + ProcessLockWait( ev.lockWait ); break; case QueueType::LockObtain: + ProcessLockObtain( ev.lockObtain ); break; case QueueType::LockRelease: + ProcessLockRelease( ev.lockRelease ); break; default: assert( false ); @@ -459,6 +462,39 @@ void View::ProcessLockAnnounce( const QueueLockAnnounce& ev ) m_lockMap.emplace( ev.id, LockMap { ev.srcloc } ); } +void View::ProcessLockWait( const QueueLockWait& ev ) +{ + auto it = m_lockMap.find( ev.id ); + if( it == m_lockMap.end() ) + { + auto& v = m_pendingLocks[ev.id]; + v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Wait } ); + return; + } +} + +void View::ProcessLockObtain( const QueueLockObtain& ev ) +{ + auto it = m_lockMap.find( ev.id ); + if( it == m_lockMap.end() ) + { + auto& v = m_pendingLocks[ev.id]; + v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Obtain } ); + return; + } +} + +void View::ProcessLockRelease( const QueueLockRelease& ev ) +{ + auto it = m_lockMap.find( ev.id ); + if( it == m_lockMap.end() ) + { + auto& v = m_pendingLocks[ev.id]; + v.push_back( LockEvent { ev.time, ev.thread, LockEvent::Type::Release } ); + return; + } +} + void View::CheckString( uint64_t ptr ) { if( m_strings.find( ptr ) != m_strings.end() ) return; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index b8a59673..c920baa7 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -64,6 +64,9 @@ private: void ProcessZoneText( const QueueZoneText& ev ); void ProcessZoneName( const QueueZoneName& ev ); void ProcessLockAnnounce( const QueueLockAnnounce& ev ); + void ProcessLockWait( const QueueLockWait& ev ); + void ProcessLockObtain( const QueueLockObtain& ev ); + void ProcessLockRelease( const QueueLockRelease& ev ); void CheckString( uint64_t ptr ); void CheckThreadString( uint64_t id ); @@ -140,6 +143,7 @@ private: std::unordered_set m_pendingSourceLocation; std::unordered_map m_pendingCustomStrings; std::unordered_map m_threadMap; + std::unordered_map> m_pendingLocks; Slab m_slab;