mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Have to track callstacks of both alloc and free.
This commit is contained in:
parent
0de279005b
commit
06f34052a5
@ -147,7 +147,8 @@ struct MemEvent
|
||||
uint64_t size;
|
||||
int64_t timeAlloc;
|
||||
int64_t timeFree;
|
||||
uint32_t callstack;
|
||||
uint32_t csAlloc;
|
||||
uint32_t csFree;
|
||||
// All above is read/saved as-is.
|
||||
|
||||
uint16_t threadAlloc;
|
||||
|
@ -553,11 +553,12 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
if( fileVer <= FileVersion( 0, 3, 1 ) )
|
||||
{
|
||||
f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) );
|
||||
mem->callstack = 0;
|
||||
mem->csAlloc = 0;
|
||||
mem->csFree = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) + sizeof( MemEvent::callstack ) );
|
||||
f.Read( mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) );
|
||||
}
|
||||
|
||||
uint64_t t0, t1;
|
||||
@ -611,7 +612,8 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
sizeof( MemEvent::size ) +
|
||||
sizeof( MemEvent::timeAlloc ) +
|
||||
sizeof( MemEvent::timeFree ) +
|
||||
sizeof( MemEvent::callstack ) +
|
||||
sizeof( MemEvent::csAlloc ) +
|
||||
sizeof( MemEvent::csFree ) +
|
||||
sizeof( uint64_t ) +
|
||||
sizeof( uint64_t ) ) );
|
||||
}
|
||||
@ -2024,7 +2026,8 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev )
|
||||
mem.threadAlloc = CompressThread( ev.thread );
|
||||
mem.timeFree = -1;
|
||||
mem.threadFree = 0;
|
||||
mem.callstack = 0;
|
||||
mem.csAlloc = 0;
|
||||
mem.csFree = 0;
|
||||
|
||||
const auto low = m_data.memory.low;
|
||||
const auto high = m_data.memory.high;
|
||||
@ -2057,12 +2060,14 @@ void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
|
||||
{
|
||||
m_lastMemActionCallstack = m_data.memory.data.size();
|
||||
ProcessMemAlloc( ev );
|
||||
m_lastMemActionWasAlloc = true;
|
||||
}
|
||||
|
||||
void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev )
|
||||
{
|
||||
ProcessMemFree( ev );
|
||||
m_lastMemActionCallstack = m_data.memory.frees.back();
|
||||
m_lastMemActionWasAlloc = false;
|
||||
}
|
||||
|
||||
void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev )
|
||||
@ -2071,7 +2076,14 @@ void Worker::ProcessCallstackMemory( const QueueCallstackMemory& ev )
|
||||
assert( it != m_pendingCallstacks.end() );
|
||||
|
||||
auto& mem = m_data.memory.data[m_lastMemActionCallstack];
|
||||
mem.callstack = it->second;
|
||||
if( m_lastMemActionWasAlloc )
|
||||
{
|
||||
mem.csAlloc = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
mem.csFree = it->second;
|
||||
}
|
||||
|
||||
m_pendingCallstacks.erase( it );
|
||||
}
|
||||
@ -2453,7 +2465,7 @@ void Worker::Write( FileWrite& f )
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
for( auto& mem : m_data.memory.data )
|
||||
{
|
||||
f.Write( &mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) + sizeof( MemEvent::callstack ) );
|
||||
f.Write( &mem, sizeof( MemEvent::ptr ) + sizeof( MemEvent::size ) + sizeof( MemEvent::timeAlloc ) + sizeof( MemEvent::timeFree ) + sizeof( MemEvent::csAlloc ) + sizeof( MemEvent::csFree ) );
|
||||
uint64_t t[2];
|
||||
t[0] = DecompressThread( mem.threadAlloc );
|
||||
t[1] = DecompressThread( mem.threadFree );
|
||||
|
@ -307,6 +307,7 @@ private:
|
||||
uint32_t m_pendingSourceLocation;
|
||||
|
||||
uint64_t m_lastMemActionCallstack;
|
||||
bool m_lastMemActionWasAlloc;
|
||||
|
||||
Slab<64*1024*1024> m_slab;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user