Add tooltip for sampled items in flame graph.

This commit is contained in:
Bartosz Taudul 2024-09-28 15:04:43 +02:00
parent 8819ea745d
commit 7465b4ffaf
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1,3 +1,5 @@
#include <inttypes.h>
#include "TracyColor.hpp" #include "TracyColor.hpp"
#include "TracyEvent.hpp" #include "TracyEvent.hpp"
#include "TracyImGui.hpp" #include "TracyImGui.hpp"
@ -243,12 +245,79 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
ImGui::PopClipRect(); ImGui::PopClipRect();
} }
if( hover && !samples ) if( hover )
{ {
uint64_t self = item.time; uint64_t self = item.time;
for( auto& v : item.children ) self -= v.time; for( auto& v : item.children ) self -= v.time;
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if( samples )
{
const auto symAddr = (uint64_t)item.srcloc;
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 )
{
ImGui::SameLine();
TextDisabledUnformatted( "[inline]" );
}
const bool isKernel = symAddr >> 63 != 0;
if( isKernel )
{
ImGui::SameLine();
TextDisabledUnformatted( ICON_FA_HAT_WIZARD " kernel" );
}
ImGui::SameLine();
ImGui::PushFont( m_smallFont );
ImGui::AlignTextToFramePadding();
ImGui::TextDisabled( "0x%" PRIx64, symAddr );
ImGui::PopFont();
if( normalized != name && strcmp( normalized, name ) != 0 )
{
ImGui::PushFont( m_smallFont );
TextDisabledUnformatted( name );
ImGui::PopFont();
}
ImGui::Separator();
const char* file;
uint32_t line;
if( sym->isInline )
{
file = m_worker.GetString( sym->callFile );
line = sym->callLine;
}
else
{
file = m_worker.GetString( sym->file );
line = sym->line;
}
if( file[0] != '[' )
{
ImGui::TextDisabled( "Location:" );
ImGui::SameLine();
ImGui::TextUnformatted( LocationToString( file, line ) );
}
TextFocused( "Image:", m_worker.GetString( sym->imageName ) );
ImGui::Separator();
const auto period = m_worker.GetSamplingPeriod();
TextFocused( "Execution time:", TimeToString( item.time * period ) );
if( !item.children.empty() )
{
TextFocused( "Self time:", TimeToString( self * period ) );
char buf[64];
PrintStringPercent( buf, 100.f * self / item.time );
ImGui::SameLine();
TextDisabledUnformatted( buf );
}
}
ImGui::EndTooltip();
}
else
{
if( srcloc->name.active ) if( srcloc->name.active )
{ {
ImGui::TextUnformatted( m_worker.GetString( srcloc->name ) ); ImGui::TextUnformatted( m_worker.GetString( srcloc->name ) );
@ -275,6 +344,7 @@ void View::DrawFlameGraphItem( const FlameGraphItem& item, FlameGraphContext& ct
m_findZone.ShowZone( item.srcloc, slName ); m_findZone.ShowZone( item.srcloc, slName );
} }
} }
}
uint64_t cts = ts; uint64_t cts = ts;
for( auto& v : item.children ) for( auto& v : item.children )