From 3e4105285356d7c94095eacb6ff2d10c6ac82f23 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 4 Oct 2024 23:38:02 +0200 Subject: [PATCH] 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. --- profiler/src/profiler/TracyView_Samples.cpp | 56 ++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index be666f6f..1814ee49 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -424,7 +424,33 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, Accu ImGui::TextUnformatted( normalized ); TooltipNormalizedName( name, normalized ); } - if( clicked ) ShowSampleParents( v.symAddr, !m_statSeparateInlines ); + if( clicked ) ImGui::OpenPopup( "menuPopup" ); + if( ImGui::BeginPopup( "menuPopup" ) ) + { + uint32_t len; + const bool sfv = SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) || ( symlen != 0 && m_worker.GetSymbolCode( codeAddr, len ) ); + if( !sfv ) ImGui::BeginDisabled(); + if( ImGui::MenuItem( " " ICON_FA_FILE_LINES " View symbol" ) ) + { + if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) ) + { + ViewSymbol( file, line, codeAddr, v.symAddr ); + if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( false ); + } + else if( symlen != 0 ) + { + uint32_t len; + if( m_worker.GetSymbolCode( codeAddr, len ) ) + { + ViewSymbol( nullptr, 0, codeAddr, v.symAddr ); + if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( false ); + } + } + } + if( !sfv ) ImGui::EndDisabled(); + if( ImGui::MenuItem( ICON_FA_ARROW_DOWN_SHORT_WIDE " Sample entry call stacks" ) ) ShowSampleParents( v.symAddr, !m_statSeparateInlines ); + ImGui::EndPopup(); + } ImGui::PopID(); } if( parentName ) @@ -618,7 +644,33 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, Accu ImGui::TextUnformatted( normalized ); TooltipNormalizedName( sn, normalized ); } - if( clicked ) ShowSampleParents( iv.symAddr, false ); + if( clicked ) ImGui::OpenPopup( "menuPopup" ); + if( ImGui::BeginPopup( "menuPopup" ) ) + { + uint32_t len; + const bool sfv = SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) || ( symlen != 0 && m_worker.GetSymbolCode( codeAddr, len ) ); + if( !sfv ) ImGui::BeginDisabled(); + if( ImGui::MenuItem( " " ICON_FA_FILE_LINES " View symbol" ) ) + { + if( SourceFileValid( file, m_worker.GetCaptureTime(), *this, m_worker ) ) + { + ViewSymbol( file, line, codeAddr, iv.symAddr ); + if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( true ); + } + else if( symlen != 0 ) + { + uint32_t len; + if( m_worker.GetSymbolCode( codeAddr, len ) ) + { + ViewSymbol( nullptr, 0, codeAddr, iv.symAddr ); + if( !m_statSeparateInlines ) m_sourceView->CalcInlineStats( true ); + } + } + } + if( !sfv ) ImGui::EndDisabled(); + if( ImGui::MenuItem( ICON_FA_ARROW_DOWN_SHORT_WIDE " Sample entry call stacks" ) ) ShowSampleParents( iv.symAddr, false ); + ImGui::EndPopup(); + } ImGui::PopID(); } if( sn == parentName )