Skip to content

Commit

Permalink
Use proper name for inline frames in flame graph.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfpld committed Oct 27, 2024
1 parent ecf3b30 commit 8471810
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions profiler/src/profiler/TracyView_FlameGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,19 @@ void View::BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& d
const auto csz = callstack.size();
for( size_t i=csz; i>0; i--)
{
auto frame = worker.GetCallstackFrame( callstack[i-1] );
if( frame )
auto frameData = worker.GetCallstackFrame( callstack[i-1] );
if( frameData )
{
for( uint8_t j=frame->size; j>0; j-- )
for( uint8_t j=frameData->size; j>0; j-- )
{
const auto symaddr = frame->data[j-1].symAddr;
const auto frame = frameData->data[j-1];
const auto symaddr = frame.symAddr;
if( symaddr != 0 )
{
auto it = std::find_if( vec->begin(), vec->end(), [symaddr]( const auto& v ) { return v.srcloc == symaddr; } );
if( it == vec->end() )
{
vec->emplace_back( FlameGraphItem { (int64_t)symaddr, 1 } );
vec->emplace_back( FlameGraphItem { (int64_t)symaddr, 1, frame.name } );
vec = &vec->back().children;
}
else
Expand Down Expand Up @@ -333,11 +334,11 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
}
else
{
name = m_worker.GetString( item.name );
const auto symAddr = (uint64_t)item.srcloc;
auto sym = m_worker.GetSymbolData( symAddr );
if( sym )
{
name = m_worker.GetString( sym->name );
auto namehash = charutil::hash( name );
if( namehash == 0 ) namehash++;
color = GetHsvColor( namehash, depth );
Expand All @@ -348,7 +349,6 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
}
else
{
name = "???";
color = 0xFF888888;
}
if( symAddr >> 63 != 0 )
Expand Down Expand Up @@ -405,7 +405,6 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
auto sym = m_worker.GetSymbolData( symAddr );
if( sym )
{
auto name = m_worker.GetString( sym->name );
auto normalized = m_vd.shortenName == ShortenName::Never ? name : ShortenZoneName( ShortenName::OnlyNormalize, name );
TextFocused( "Name:", normalized );
if( sym->isInline )
Expand Down
1 change: 1 addition & 0 deletions server/TracyEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ struct FlameGraphItem
{
int64_t srcloc;
int64_t time;
StringIdx name;
int64_t begin;
std::vector<FlameGraphItem> children;
};
Expand Down

0 comments on commit 8471810

Please sign in to comment.