1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Capture kernel frames on Linux.

Garbage frames ("markers") have to be filtered out.
This commit is contained in:
Bartosz Taudul 2021-06-12 14:35:43 +02:00
parent ed50447f7a
commit 0a954fda87
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -780,7 +780,6 @@ static void SetupSampling( int64_t& samplingPeriod )
#if LINUX_VERSION_CODE >= KERNEL_VERSION( 4, 8, 0 ) #if LINUX_VERSION_CODE >= KERNEL_VERSION( 4, 8, 0 )
pe.sample_max_stack = 127; pe.sample_max_stack = 127;
#endif #endif
pe.exclude_callchain_kernel = 1;
pe.disabled = 1; pe.disabled = 1;
pe.freq = 1; pe.freq = 1;
pe.inherit = 1; pe.inherit = 1;
@ -999,31 +998,22 @@ static void SetupSampling( int64_t& samplingPeriod )
} }
#endif #endif
// skip kernel frames for( uint64_t j=1; j<=cnt; j++ )
uint64_t j;
for( j=0; j<cnt; j++ )
{ {
if( (int64_t)trace[j+1] >= 0 ) break; if( trace[j] >= (uint64_t)-4095 ) // PERF_CONTEXT_MAX
}
if( j == cnt )
{
tracy_free_fast( trace );
}
else
{
if( j > 0 )
{ {
cnt -= j; memmove( trace+j, trace+j+1, sizeof( uint64_t ) * ( cnt - j ) );
memmove( trace+1, trace+1+j, sizeof( uint64_t ) * cnt ); cnt--;
} }
memcpy( trace, &cnt, sizeof( uint64_t ) );
TracyLfqPrepare( QueueType::CallstackSample );
MemWrite( &item->callstackSampleFat.time, t0 );
MemWrite( &item->callstackSampleFat.thread, (uint64_t)tid );
MemWrite( &item->callstackSampleFat.ptr, (uint64_t)trace );
TracyLfqCommit;
} }
memcpy( trace, &cnt, sizeof( uint64_t ) );
TracyLfqPrepare( QueueType::CallstackSample );
MemWrite( &item->callstackSampleFat.time, t0 );
MemWrite( &item->callstackSampleFat.thread, (uint64_t)tid );
MemWrite( &item->callstackSampleFat.ptr, (uint64_t)trace );
TracyLfqCommit;
} }
} }
} }