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.
This commit is contained in:
Bartosz Taudul 2024-10-04 23:38:02 +02:00
parent 384646b03b
commit 3e41052853
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -424,7 +424,33 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
ImGui::TextUnformatted( normalized ); ImGui::TextUnformatted( normalized );
TooltipNormalizedName( name, 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(); ImGui::PopID();
} }
if( parentName ) if( parentName )
@ -618,7 +644,33 @@ void View::DrawSamplesStatistics( Vector<SymList>& data, int64_t timeRange, Accu
ImGui::TextUnformatted( normalized ); ImGui::TextUnformatted( normalized );
TooltipNormalizedName( sn, 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(); ImGui::PopID();
} }
if( sn == parentName ) if( sn == parentName )