1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

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
+28 -32
View File
@@ -16105,43 +16105,39 @@ void View::DrawSampleParents()
ImGui::Begin( "Sample entry call stacks", &show, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse );
if( !ImGui::GetCurrentWindowRead()->SkipItems )
{
const SymbolStats* stats;
SymbolStats tmpss;
auto ss = m_worker.GetSymbolStats( m_sampleParents.symAddr );
auto excl = ss->excl;
auto stats = ss->parents;
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();
auto inSym = m_worker.GetInlineSymbolList( m_sampleParents.symAddr, symlen );
assert( inSym != nullptr );
const auto symEnd = m_sampleParents.symAddr + symlen;
while( *inSym < symEnd )
if( inSym )
{
auto istat = m_worker.GetSymbolStats( *inSym++ );
if( !istat ) continue;
tmpss.incl += istat->incl;
tmpss.excl += istat->excl;
for( auto& v : istat->parents )
const auto symEnd = m_sampleParents.symAddr + symlen;
while( *inSym < symEnd )
{
auto it = tmpss.parents.find( v.first );
if( it == tmpss.parents.end() )
auto istat = m_worker.GetSymbolStats( *inSym++ );
if( !istat ) continue;
excl += istat->excl;
for( auto& v : istat->baseParents )
{
tmpss.parents.emplace( v.first, v.second );
}
else
{
it->second += v.second;
auto it = stats.find( v.first );
if( it == stats.end() )
{
stats.emplace( v.first, v.second );
}
else
{
it->second += v.second;
}
}
}
}
stats = &tmpss;
}
assert( !stats->parents.empty() );
assert( !stats.empty() );
ImGui::PushFont( m_bigFont );
TextFocused( "Symbol:", m_worker.GetString( symbol->name ) );
@@ -16184,30 +16180,30 @@ void View::DrawSampleParents()
m_sampleParents.sel = std::max( m_sampleParents.sel - 1, 0 );
}
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" );
ImGui::SameLine();
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" ) )
{
int sel = m_sampleParents.sel + 1;
ImGui::SetNextItemWidth( 120 * scale );
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();
}
Vector<decltype(stats->parents.begin())> data;
data.reserve( stats->parents.size() );
for( auto it = stats->parents.begin(); it != stats->parents.end(); ++it ) data.push_back( it );
Vector<decltype(stats.begin())> data;
data.reserve( stats.size() );
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; } );
ImGui::SameLine();
ImGui::TextUnformatted( m_statSampleTime ? TimeToString( m_worker.GetSamplingPeriod() * data[m_sampleParents.sel]->second ) : RealToString( data[m_sampleParents.sel]->second ) );
ImGui::SameLine();
char buf[64];
PrintStringPercent( buf, 100. * data[m_sampleParents.sel]->second / stats->excl );
PrintStringPercent( buf, 100. * data[m_sampleParents.sel]->second / excl );
TextDisabledUnformatted( buf );
ImGui::SameLine();
ImGui::Spacing();