Skip to content

Commit 7fc3366

Browse files
committed
Add support for keeping external tails in flame graph.
1 parent 99d39e6 commit 7fc3366

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

profiler/src/profiler/TracyView_FlameGraph.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ void View::BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& d
214214
{
215215
uint64_t symaddr;
216216
StringIdx name;
217+
bool external;
217218
};
218219

219220
std::vector<FrameCache> cache;
@@ -244,7 +245,7 @@ void View::BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& d
244245
}
245246
}
246247
}
247-
else
248+
else if( !m_flameExternalTail )
248249
{
249250
for( size_t i=csz; i>0; i-- )
250251
{
@@ -268,6 +269,41 @@ void View::BuildFlameGraph( const Worker& worker, std::vector<FlameGraphItem>& d
268269
}
269270
}
270271
}
272+
else
273+
{
274+
for( size_t i=csz; i>0; i-- )
275+
{
276+
auto frameData = worker.GetCallstackFrame( callstack[i-1] );
277+
if( frameData )
278+
{
279+
for( uint8_t j=frameData->size; j>0; j-- )
280+
{
281+
const auto frame = frameData->data[j-1];
282+
const auto symaddr = frame.symAddr;
283+
if( symaddr != 0 )
284+
{
285+
auto filename = m_worker.GetString( frame.file );
286+
auto image = frameData->imageName.Active() ? m_worker.GetString( frameData->imageName ) : nullptr;
287+
cache.emplace_back( FrameCache { symaddr, frame.name, IsFrameExternal( filename, image ) } );
288+
}
289+
}
290+
}
291+
}
292+
293+
bool tail = true;
294+
for( size_t i=cache.size(); i>0; i-- )
295+
{
296+
const auto idx = i-1;
297+
if( !cache[idx].external )
298+
{
299+
tail = false;
300+
}
301+
else if( !tail )
302+
{
303+
cache.erase( cache.begin() + idx );
304+
}
305+
}
306+
}
271307

272308
auto vec = &data;
273309
for( auto& v : cache )

0 commit comments

Comments
 (0)