Determine sample type.

This commit is contained in:
Bartosz Taudul
2026-06-27 11:55:00 +02:00
parent 323659d4f7
commit 90d4463ef0
2 changed files with 41 additions and 1 deletions

View File

@@ -43,10 +43,18 @@ struct ContextSwitchDraw
};
enum class SampleType
{
Own,
External,
Kernel
};
struct SamplesDraw
{
uint32_t num;
uint32_t idx;
SampleType type;
};

View File

@@ -625,7 +625,39 @@ void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Ve
nextTime = nt + MinVisNs;
}
}
m_samplesDraw.emplace_back( SamplesDraw { uint32_t( next - it - 1 ), uint32_t( it - vec.begin() ) } );
const auto num = uint32_t( next - it - 1 );
const auto idx = uint32_t( it - vec.begin() );
if( num == 0 )
{
auto type = SampleType::Own;
auto& cs = m_worker.GetCallstack( it->callstack.Val() );
auto frameData = m_worker.GetCallstackFrame( cs[0] );
if( frameData )
{
const auto& frame = frameData->data[0];
if( frame.symAddr >> 63 != 0 )
{
type = SampleType::Kernel;
}
else if( m_worker.IsFrameExternal( frame.file, frameData->imageName ) )
{
type = SampleType::External;
}
}
m_samplesDraw.emplace_back( SamplesDraw {
.num = 0,
.idx = idx,
.type = type
} );
}
else
{
m_samplesDraw.emplace_back( SamplesDraw {
.num = num,
.idx = idx
} );
}
it = next;
}
}