diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 11298cc7..a4012af8 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -90,11 +90,6 @@ public: SetVal( val ); } - Int24( const Int24& ) = delete; - Int24( Int24&& ) = delete; - Int24& operator=( const Int24& ) = delete; - Int24& operator=( Int24&& ) = delete; - void SetVal( uint32_t val ) { memcpy( m_val, &val, 3 ); @@ -220,8 +215,8 @@ struct MemEvent uint64_t ptr; uint64_t size; - uint32_t csAlloc; - uint32_t csFree; + Int24 csAlloc; + Int24 csFree; uint64_t _time_thread_alloc; uint64_t _time_thread_free; }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e96148ba..83564217 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -10008,10 +10008,10 @@ void View::DrawMemoryAllocWindow() ImGui::TextDisabled( "(%s)", RealToString( tidAlloc, true ) ); ImGui::SameLine(); SmallColorBox( GetThreadColor( tidAlloc, 0 ) ); - if( ev.csAlloc != 0 ) + if( ev.csAlloc.Val() != 0 ) { ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); - SmallCallstackButton( "Call stack", ev.csAlloc, idx ); + SmallCallstackButton( "Call stack", ev.csAlloc.Val(), idx ); } if( ev.TimeFree() < 0 ) { @@ -10027,10 +10027,10 @@ void View::DrawMemoryAllocWindow() ImGui::TextDisabled( "(%s)", RealToString( tidFree, true ) ); ImGui::SameLine(); SmallColorBox( GetThreadColor( tidFree, 0 ) ); - if( ev.csFree != 0 ) + if( ev.csFree.Val() != 0 ) { ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); - SmallCallstackButton( "Call stack", ev.csFree, idx ); + SmallCallstackButton( "Call stack", ev.csFree.Val(), idx ); } TextFocused( "Duration:", TimeToString( ev.TimeFree() - ev.TimeAlloc() ) ); } @@ -11488,24 +11488,24 @@ void View::ListMemData( T ptr, T end, std::function DrawAddress, const } } ImGui::NextColumn(); - if( v->csAlloc == 0 ) + if( v->csAlloc.Val() == 0 ) { TextDisabledUnformatted( "[alloc]" ); } else { - SmallCallstackButton( "alloc", v->csAlloc, idx ); + SmallCallstackButton( "alloc", v->csAlloc.Val(), idx ); } ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); - if( v->csFree == 0 ) + if( v->csFree.Val() == 0 ) { TextDisabledUnformatted( "[free]" ); } else { - SmallCallstackButton( "free", v->csFree, idx ); + SmallCallstackButton( "free", v->csFree.Val(), idx ); } ImGui::NextColumn(); ptr++; @@ -11549,14 +11549,14 @@ flat_hash_map> View::GetCallstackPath { for( auto& ev : mem.data ) { - if( ev.csAlloc == 0 ) continue; + if( ev.csAlloc.Val() == 0 ) continue; if( ev.TimeAlloc() >= zvMid ) continue; if( onlyActive && ev.TimeFree() >= 0 && ev.TimeFree() < zvMid ) continue; - auto it = pathSum.find( ev.csAlloc ); + auto it = pathSum.find( ev.csAlloc.Val() ); if( it == pathSum.end() ) { - pathSum.emplace( ev.csAlloc, PathData { 1, ev.size } ); + pathSum.emplace( ev.csAlloc.Val(), PathData { 1, ev.size } ); } else { @@ -11569,13 +11569,13 @@ flat_hash_map> View::GetCallstackPath { for( auto& ev : mem.data ) { - if( ev.csAlloc == 0 ) continue; + if( ev.csAlloc.Val() == 0 ) continue; if( onlyActive && ev.TimeFree() >= 0 ) continue; - auto it = pathSum.find( ev.csAlloc ); + auto it = pathSum.find( ev.csAlloc.Val() ); if( it == pathSum.end() ) { - pathSum.emplace( ev.csAlloc, PathData { 1, ev.size } ); + pathSum.emplace( ev.csAlloc.Val(), PathData { 1, ev.size } ); } else { @@ -12196,7 +12196,7 @@ void View::DrawFrameTreeLevel( const flat_hash_map= FileVersion( 0, 5, 2 ) ) + if( fileVer >= FileVersion( 0, 5, 9 ) ) { auto& frees = m_data.memory.frees; auto& active = m_data.memory.active; @@ -1140,6 +1140,39 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) mem++; } } + else if( fileVer >= FileVersion( 0, 5, 2 ) ) + { + auto& frees = m_data.memory.frees; + auto& active = m_data.memory.active; + + for( uint64_t i=0; icsFree, sizeof( MemEvent::csFree ) ); + f.Skip( 1 ); + int64_t timeAlloc, timeFree; + uint16_t threadAlloc, threadFree; + f.Read2( timeAlloc, timeFree ); + f.Read2( threadAlloc, threadFree ); + refTime += timeAlloc; + mem->SetTimeAlloc( refTime ); + if( timeFree >= 0 ) + { + mem->SetTimeFree( timeFree + refTime ); + frees[fidx++] = i; + } + else + { + mem->SetTimeFree( timeFree ); + active.emplace( mem->ptr, i ); + } + mem->SetThreadAlloc( threadAlloc ); + mem->SetThreadFree( threadFree ); + mem++; + } + } else if( fileVer >= FileVersion( 0, 4, 4 ) ) { auto& frees = m_data.memory.frees; @@ -1151,7 +1184,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) ); int64_t timeAlloc, timeFree; f.Read2( timeAlloc, timeFree ); - f.Read( &mem->csAlloc, sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) ); + f.Read( mem->csAlloc ); + f.Skip( 1 ); + f.Read( mem->csFree ); + f.Skip( 1 ); uint16_t threadAlloc, threadFree; f.Read2( threadAlloc, threadFree ); refTime += timeAlloc; @@ -1181,7 +1217,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) ); int64_t timeAlloc, timeFree; f.Read2( timeAlloc, timeFree ); - f.Read( &mem->csAlloc, sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) ); + f.Read( mem->csAlloc ); + f.Skip( 1 ); + f.Read( mem->csFree ); + f.Skip( 1 ); refTime += timeAlloc; mem->SetTimeAlloc( refTime - m_data.baseTime ); if( timeFree >= 0 ) @@ -1198,7 +1237,10 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) ); int64_t timeAlloc, timeFree; f.Read2( timeAlloc, timeFree ); - f.Read( &mem->csAlloc, sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) ); + f.Read( mem->csAlloc ); + f.Skip( 1 ); + f.Read( mem->csFree ); + f.Skip( 1 ); mem->SetTimeAlloc( timeAlloc - m_data.baseTime ); if( timeFree >= 0 ) { @@ -1248,21 +1290,21 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) { f.Skip( 2 * sizeof( uint64_t ) ); - if( fileVer >= FileVersion( 0, 5, 2 ) ) + if( fileVer >= FileVersion( 0, 5, 9 ) ) { f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) + sizeof( int64_t ) * 2 + sizeof( uint16_t ) * 2 ) ); } + else if( fileVer >= FileVersion( 0, 5, 2 ) ) + { + f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( uint32_t ) + sizeof( uint32_t ) + sizeof( int64_t ) * 2 + sizeof( uint16_t ) * 2 ) ); + } else if( fileVer >= FileVersion( 0, 4, 4 ) ) { - f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( int64_t ) + sizeof( int64_t ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) + sizeof( uint16_t ) + sizeof( uint16_t ) ) ); - } - else if( fileVer > FileVersion( 0, 4, 1 ) ) - { - f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( int64_t ) + sizeof( int64_t ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) + 2 * sizeof( uint64_t ) ) ); + f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( int64_t ) + sizeof( int64_t ) + sizeof( uint32_t ) + sizeof( uint32_t ) + sizeof( uint16_t ) + sizeof( uint16_t ) ) ); } else { - f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( int64_t ) + sizeof( int64_t ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) + 2 * sizeof( uint64_t ) ) ); + f.Skip( sz * ( sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( int64_t ) + sizeof( int64_t ) + sizeof( uint32_t ) + sizeof( uint32_t ) + 2 * sizeof( uint64_t ) ) ); } f.Skip( sizeof( MemData::high ) + sizeof( MemData::low ) + sizeof( MemData::usage ) ); @@ -4087,8 +4129,8 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev ) mem.SetThreadAlloc( CompressThread( ev.thread ) ); mem.SetTimeFree( -1 ); mem.SetThreadFree( 0 ); - mem.csAlloc = 0; - mem.csFree = 0; + mem.csAlloc.SetVal( 0 ); + mem.csFree.SetVal( 0 ); const auto low = m_data.memory.low; const auto high = m_data.memory.high; @@ -4160,11 +4202,11 @@ void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev ) auto& mem = m_data.memory.data[m_lastMemActionCallstack]; if( m_lastMemActionWasAlloc ) { - mem.csAlloc = m_pendingCallstackId; + mem.csAlloc.SetVal( m_pendingCallstackId ); } else { - mem.csFree = m_pendingCallstackId; + mem.csFree.SetVal( m_pendingCallstackId ); } } }