mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-12 11:55:22 +00:00
Process section enter / leave events.
This commit is contained in:
@@ -683,6 +683,14 @@ struct ChildSample
|
||||
uint64_t addr;
|
||||
};
|
||||
|
||||
|
||||
struct SectionItem
|
||||
{
|
||||
Int48 start, end;
|
||||
StringIdx text;
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
|
||||
|
||||
@@ -7378,10 +7378,58 @@ void Worker::ProcessFiberLeave( const QueueFiberLeave& ev )
|
||||
|
||||
void Worker::ProcessSectionEnter( const QueueSectionEnter& ev )
|
||||
{
|
||||
const auto t = TscTime( RefTime( m_refTimeThread, ev.time ) );
|
||||
if( m_data.lastTime < t ) m_data.lastTime = t;
|
||||
const auto text = GetSingleStringIdx();
|
||||
|
||||
const auto ait = m_data.sectionsActive.find( ev.id );
|
||||
if( ait != m_data.sectionsActive.end() )
|
||||
{
|
||||
m_data.sectionsActive.erase( ait );
|
||||
auto it = std::ranges::find_if( m_data.sectionsPending, [id = ev.id]( const auto& s ) { return s.id == id; } );
|
||||
assert( it != m_data.sectionsPending.end() );
|
||||
assert( it->start.Val() < 0 );
|
||||
assert( !it->text.Active() );
|
||||
it->start.SetVal( t );
|
||||
it->text.SetIdx( text );
|
||||
m_data.sections.push_back( *it );
|
||||
m_data.sectionsPending.erase( it );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.sections.push_back( SectionItem {
|
||||
.start = t,
|
||||
.end = -1,
|
||||
.text = StringIdx( text ),
|
||||
.id = ev.id
|
||||
} );
|
||||
m_data.sectionsActive.insert( ev.id );
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::ProcessSectionLeave( const QueueSectionLeave& ev )
|
||||
{
|
||||
const auto t = TscTime( RefTime( m_refTimeThread, ev.time ) );
|
||||
if( m_data.lastTime < t ) m_data.lastTime = t;
|
||||
|
||||
const auto ait = m_data.sectionsActive.find( ev.id );
|
||||
if( ait != m_data.sectionsActive.end() )
|
||||
{
|
||||
m_data.sectionsActive.erase( ait );
|
||||
auto it = std::ranges::find_if( m_data.sections, [id = ev.id]( const auto& s ) { return s.id == id; } );
|
||||
assert( it != m_data.sections.end() );
|
||||
assert( it->end.Val() < 0 );
|
||||
it->end.SetVal( t );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_data.sectionsPending.push_back( SectionItem {
|
||||
.start = -1,
|
||||
.end = t,
|
||||
.id = ev.id
|
||||
} );
|
||||
m_data.sectionsActive.insert( ev.id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -407,6 +407,10 @@ private:
|
||||
bool hasBranchRetirement = false;
|
||||
|
||||
unordered_flat_map<uint64_t, uint64_t> fiberToThreadMap;
|
||||
|
||||
Vector<SectionItem> sections;
|
||||
Vector<SectionItem> sectionsPending;
|
||||
unordered_flat_set<uint64_t> sectionsActive;
|
||||
};
|
||||
|
||||
struct MbpsBlock
|
||||
|
||||
Reference in New Issue
Block a user