Fix sample parents for the whole symbol.

Previously when whole symbol was selected, it wasn't. All the inlines were
ignored and the data was displayed only for the base (self) symbol.
This commit is contained in:
Bartosz Taudul 2021-11-27 17:55:18 +01:00
parent d8a611e952
commit 582fcd5538
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -16105,33 +16105,29 @@ void View::DrawSampleParents()
ImGui::Begin( "Sample entry call stacks", &show, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); ImGui::Begin( "Sample entry call stacks", &show, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse );
if( !ImGui::GetCurrentWindowRead()->SkipItems ) if( !ImGui::GetCurrentWindowRead()->SkipItems )
{ {
const SymbolStats* stats; auto ss = m_worker.GetSymbolStats( m_sampleParents.symAddr );
SymbolStats tmpss; auto excl = ss->excl;
auto stats = ss->parents;
const auto symbol = m_worker.GetSymbolData( m_sampleParents.symAddr ); const auto symbol = m_worker.GetSymbolData( m_sampleParents.symAddr );
if( symbol->isInline || !m_sampleParents.withInlines ) if( !symbol->isInline && m_sampleParents.withInlines )
{ {
stats = m_worker.GetSymbolStats( m_sampleParents.symAddr );
}
else
{
tmpss = *m_worker.GetSymbolStats( m_sampleParents.symAddr );
const auto symlen = symbol->size.Val(); const auto symlen = symbol->size.Val();
auto inSym = m_worker.GetInlineSymbolList( m_sampleParents.symAddr, symlen ); auto inSym = m_worker.GetInlineSymbolList( m_sampleParents.symAddr, symlen );
assert( inSym != nullptr ); if( inSym )
{
const auto symEnd = m_sampleParents.symAddr + symlen; const auto symEnd = m_sampleParents.symAddr + symlen;
while( *inSym < symEnd ) while( *inSym < symEnd )
{ {
auto istat = m_worker.GetSymbolStats( *inSym++ ); auto istat = m_worker.GetSymbolStats( *inSym++ );
if( !istat ) continue; if( !istat ) continue;
tmpss.incl += istat->incl; excl += istat->excl;
tmpss.excl += istat->excl; for( auto& v : istat->baseParents )
for( auto& v : istat->parents )
{ {
auto it = tmpss.parents.find( v.first ); auto it = stats.find( v.first );
if( it == tmpss.parents.end() ) if( it == stats.end() )
{ {
tmpss.parents.emplace( v.first, v.second ); stats.emplace( v.first, v.second );
} }
else else
{ {
@ -16139,9 +16135,9 @@ void View::DrawSampleParents()
} }
} }
} }
stats = &tmpss;
} }
assert( !stats->parents.empty() ); }
assert( !stats.empty() );
ImGui::PushFont( m_bigFont ); ImGui::PushFont( m_bigFont );
TextFocused( "Symbol:", m_worker.GetString( symbol->name ) ); TextFocused( "Symbol:", m_worker.GetString( symbol->name ) );
@ -16184,30 +16180,30 @@ void View::DrawSampleParents()
m_sampleParents.sel = std::max( m_sampleParents.sel - 1, 0 ); m_sampleParents.sel = std::max( m_sampleParents.sel - 1, 0 );
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text( "%s / %s", RealToString( m_sampleParents.sel + 1 ), RealToString( stats->parents.size() ) ); ImGui::Text( "%s / %s", RealToString( m_sampleParents.sel + 1 ), RealToString( stats.size() ) );
if( ImGui::IsItemClicked() ) ImGui::OpenPopup( "EntryCallStackPopup" ); if( ImGui::IsItemClicked() ) ImGui::OpenPopup( "EntryCallStackPopup" );
ImGui::SameLine(); ImGui::SameLine();
if( ImGui::SmallButton( " " ICON_FA_CARET_RIGHT " " ) ) if( ImGui::SmallButton( " " ICON_FA_CARET_RIGHT " " ) )
{ {
m_sampleParents.sel = std::min<int>( m_sampleParents.sel + 1, stats->parents.size() - 1 ); m_sampleParents.sel = std::min<int>( m_sampleParents.sel + 1, stats.size() - 1 );
} }
if( ImGui::BeginPopup( "EntryCallStackPopup" ) ) if( ImGui::BeginPopup( "EntryCallStackPopup" ) )
{ {
int sel = m_sampleParents.sel + 1; int sel = m_sampleParents.sel + 1;
ImGui::SetNextItemWidth( 120 * scale ); ImGui::SetNextItemWidth( 120 * scale );
const bool clicked = ImGui::InputInt( "##entryCallStack", &sel, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue ); const bool clicked = ImGui::InputInt( "##entryCallStack", &sel, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue );
if( clicked ) m_sampleParents.sel = std::min( std::max( sel, 1 ), int( stats->parents.size() ) ) - 1; if( clicked ) m_sampleParents.sel = std::min( std::max( sel, 1 ), int( stats.size() ) ) - 1;
ImGui::EndPopup(); ImGui::EndPopup();
} }
Vector<decltype(stats->parents.begin())> data; Vector<decltype(stats.begin())> data;
data.reserve( stats->parents.size() ); data.reserve( stats.size() );
for( auto it = stats->parents.begin(); it != stats->parents.end(); ++it ) data.push_back( it ); for( auto it = stats.begin(); it != stats.end(); ++it ) data.push_back( it );
pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second > r->second; } ); pdqsort_branchless( data.begin(), data.end(), []( const auto& l, const auto& r ) { return l->second > r->second; } );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( m_statSampleTime ? TimeToString( m_worker.GetSamplingPeriod() * data[m_sampleParents.sel]->second ) : RealToString( data[m_sampleParents.sel]->second ) ); ImGui::TextUnformatted( m_statSampleTime ? TimeToString( m_worker.GetSamplingPeriod() * data[m_sampleParents.sel]->second ) : RealToString( data[m_sampleParents.sel]->second ) );
ImGui::SameLine(); ImGui::SameLine();
char buf[64]; char buf[64];
PrintStringPercent( buf, 100. * data[m_sampleParents.sel]->second / stats->excl ); PrintStringPercent( buf, 100. * data[m_sampleParents.sel]->second / excl );
TextDisabledUnformatted( buf ); TextDisabledUnformatted( buf );
ImGui::SameLine(); ImGui::SameLine();
ImGui::Spacing(); ImGui::Spacing();