Update lock ranges when loading trace.

This commit is contained in:
Bartosz Taudul 2019-03-16 02:28:32 +01:00
parent 8ced8a457c
commit 67f14be6aa

View File

@ -213,6 +213,14 @@ static tracy_force_inline int64_t ReadTimeOffset( FileRead& f, int64_t& refTime
return refTime; return refTime;
} }
static tracy_force_inline void UpdateLockRange( LockMap& lockmap, const LockEvent& ev )
{
const auto lt = ev.time;
auto& range = lockmap.range[ev.thread];
if( range.start > lt ) range.start = lt;
if( range.end < lt ) range.end = lt;
}
LoadProgress Worker::s_loadProgress; LoadProgress Worker::s_loadProgress;
Worker::Worker( const char* addr ) Worker::Worker( const char* addr )
@ -604,6 +612,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
lev->time = ReadTimeOffset( f, refTime ); lev->time = ReadTimeOffset( f, refTime );
f.Read( &lev->srcloc, sizeof( LockEvent::srcloc ) + sizeof( LockEvent::thread ) + sizeof( LockEvent::type ) ); f.Read( &lev->srcloc, sizeof( LockEvent::srcloc ) + sizeof( LockEvent::thread ) + sizeof( LockEvent::type ) );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
else else
@ -614,6 +623,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
lev->time = ReadTimeOffset( f, refTime ); lev->time = ReadTimeOffset( f, refTime );
f.Read( &lev->srcloc, sizeof( LockEventShared::srcloc ) + sizeof( LockEventShared::thread ) + sizeof( LockEventShared::type ) ); f.Read( &lev->srcloc, sizeof( LockEventShared::srcloc ) + sizeof( LockEventShared::thread ) + sizeof( LockEventShared::type ) );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
} }
@ -626,6 +636,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
auto lev = m_slab.Alloc<LockEvent>(); auto lev = m_slab.Alloc<LockEvent>();
f.Read( lev, sizeof( LockEvent::time ) + sizeof( LockEvent::srcloc ) + sizeof( LockEvent::thread ) + sizeof( LockEvent::type ) ); f.Read( lev, sizeof( LockEvent::time ) + sizeof( LockEvent::srcloc ) + sizeof( LockEvent::thread ) + sizeof( LockEvent::type ) );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
else else
@ -635,6 +646,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
auto lev = m_slab.Alloc<LockEventShared>(); auto lev = m_slab.Alloc<LockEventShared>();
f.Read( lev, sizeof( LockEventShared::time ) + sizeof( LockEventShared::srcloc ) + sizeof( LockEventShared::thread ) + sizeof( LockEventShared::type ) ); f.Read( lev, sizeof( LockEventShared::time ) + sizeof( LockEventShared::srcloc ) + sizeof( LockEventShared::thread ) + sizeof( LockEventShared::type ) );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
} }
@ -650,6 +662,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
f.Read( lev->type ); f.Read( lev->type );
f.Skip( sizeof( uint8_t ) + sizeof( uint64_t ) ); f.Skip( sizeof( uint8_t ) + sizeof( uint64_t ) );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
else else
@ -662,6 +675,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
f.Read( lev->type ); f.Read( lev->type );
f.Skip( sizeof( uint8_t ) + sizeof( uint64_t ) * 3 ); f.Skip( sizeof( uint8_t ) + sizeof( uint64_t ) * 3 );
*ptr++ = lev; *ptr++ = lev;
UpdateLockRange( lockmap, *lev );
} }
} }
} }