Skip to content

Commit 3e41052

Browse files
committed
Add context menu to left-click on item in symbol statistics list.
The context menu contains two items: 1. "View symbol", which shows the symbol code / disassembly. This was previously available by right-clicking on the source file name. 2. "Sample entry call stacks", which brings up the list window that was previously available with left-click on the entry line. This change intends to make the symbol view easier to discover.
1 parent 384646b commit 3e41052

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

profiler/src/profiler/TracyView_Samples.cpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,33 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
424424
ImGui::TextUnformatted( normalized );
425425
TooltipNormalizedName( name, normalized );
426426
}
427-
if( clicked ) ShowSampleParents( v.symAddr, !m_statSeparateInlines );
427+
if( clicked ) ImGui::OpenPopup( "menuPopup" );
428+
if( ImGui::BeginPopup( "menuPopup" ) )
429+
{
430+
uint32_t len;
431+
const bool sfv = SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) || ( symlen != 0 && m_worker.GetSymbolCode( codeAddr, len ) );
432+
if( !sfv ) ImGui::BeginDisabled();
433+
if( ImGui::MenuItem( " " ICON_FA_FILE_LINES " View symbol" ) )
434+
{
435+
if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) )
436+
{
437+
ViewSymbol( file, line, codeAddr, v.symAddr );
438+
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( false );
439+
}
440+
else if( symlen != 0 )
441+
{
442+
uint32_t len;
443+
if( m_worker.GetSymbolCode( codeAddr, len ) )
444+
{
445+
ViewSymbol( nullptr, 0, codeAddr, v.symAddr );
446+
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( false );
447+
}
448+
}
449+
}
450+
if( !sfv ) ImGui::EndDisabled();
451+
if( ImGui::MenuItem( ICON_FA_ARROW_DOWN_SHORT_WIDE " Sample entry call stacks" ) ) ShowSampleParents( v.symAddr, !m_statSeparateInlines );
452+
ImGui::EndPopup();
453+
}
428454
ImGui::PopID();
429455
}
430456
if( parentName )
@@ -618,7 +644,33 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
618644
ImGui::TextUnformatted( normalized );
619645
TooltipNormalizedName( sn, normalized );
620646
}
621-
if( clicked ) ShowSampleParents( iv.symAddr, false );
647+
if( clicked ) ImGui::OpenPopup( "menuPopup" );
648+
if( ImGui::BeginPopup( "menuPopup" ) )
649+
{
650+
uint32_t len;
651+
const bool sfv = SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) || ( symlen != 0 && m_worker.GetSymbolCode( codeAddr, len ) );
652+
if( !sfv ) ImGui::BeginDisabled();
653+
if( ImGui::MenuItem( " " ICON_FA_FILE_LINES " View symbol" ) )
654+
{
655+
if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) )
656+
{
657+
ViewSymbol( file, line, codeAddr, iv.symAddr );
658+
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( true );
659+
}
660+
else if( symlen != 0 )
661+
{
662+
uint32_t len;
663+
if( m_worker.GetSymbolCode( codeAddr, len ) )
664+
{
665+
ViewSymbol( nullptr, 0, codeAddr, iv.symAddr );
666+
if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( true );
667+
}
668+
}
669+
}
670+
if( !sfv ) ImGui::EndDisabled();
671+
if( ImGui::MenuItem( ICON_FA_ARROW_DOWN_SHORT_WIDE " Sample entry call stacks" ) ) ShowSampleParents( iv.symAddr, false );
672+
ImGui::EndPopup();
673+
}
622674
ImGui::PopID();
623675
}
624676
if( sn == parentName )

0 commit comments

Comments
 (0)