Gather child IP stats for addresses without samples.

This commit is contained in:
Bartosz Taudul 2021-04-18 21:09:20 +02:00
parent ef93c69ee9
commit 66ef71cf7b
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 58 additions and 0 deletions

View File

@ -1099,6 +1099,7 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view )
if( m_calcInlineStats ) if( m_calcInlineStats )
{ {
GatherIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view ); GatherIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
GatherAdditionalIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
} }
else else
{ {
@ -1113,6 +1114,7 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view )
iptr++; iptr++;
} }
} }
GatherAdditionalIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
iptotalSrc = iptotalAsm; iptotalSrc = iptotalAsm;
} }
if( ( iptotalAsm.local + iptotalAsm.ext ) > 0 || ( view.m_statRange.active && worker.GetSamplesForSymbol( m_baseAddr ) ) ) if( ( iptotalAsm.local + iptotalAsm.ext ) > 0 || ( view.m_statRange.active && worker.GetSamplesForSymbol( m_baseAddr ) ) )
@ -3402,6 +3404,61 @@ void SourceView::GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrSta
} }
} }
void SourceView::GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view )
{
if( !worker.AreSourceLocationZonesReady() ) return;
auto filename = m_source.filename();
if( limitView )
{
}
else
{
auto sym = worker.GetSymbolData( baseAddr );
if( sym )
{
for( uint64_t ip = baseAddr; ip < baseAddr + sym->size.Val(); ip++ )
{
if( ipcountAsm.find( ip ) != ipcountAsm.end() ) continue;
auto cp = worker.GetChildSamples( ip );
if( !cp ) continue;
const auto ccnt = (uint32_t)cp->size();
ipcountAsm.emplace( ip, AddrStat { 0, ccnt } );
iptotalAsm.ext += ccnt;
if( ipmaxAsm.ext < ccnt ) ipmaxAsm.ext = ccnt;
if( filename )
{
auto frame = worker.GetCallstackFrame( worker.PackPointer( ip ) );
if( frame )
{
auto ffn = worker.GetString( frame->data[0].file );
if( strcmp( ffn, filename ) == 0 )
{
const auto line = frame->data[0].line;
if( line != 0 )
{
auto it = ipcountSrc.find( line );
if( it == ipcountSrc.end() )
{
ipcountSrc.emplace( line, AddrStat{ 0, ccnt } );
if( ipmaxSrc.ext < ccnt ) ipmaxSrc.ext = ccnt;
}
else
{
const auto csum = it->second.ext + ccnt;
it->second.ext = csum;
if( ipmaxSrc.ext < csum ) ipmaxSrc.ext = csum;
}
iptotalSrc.ext += ccnt;
}
}
}
}
}
}
}
}
uint32_t SourceView::CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view ) uint32_t SourceView::CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view )
{ {
if( limitView ) if( limitView )

View File

@ -147,6 +147,7 @@ private:
void SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker ); void SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker );
void GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view ); void GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view );
void GatherAdditionalIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map<uint64_t, AddrStat>& ipcountSrc, unordered_flat_map<uint64_t, AddrStat>& ipcountAsm, AddrStat& ipmaxSrc, AddrStat& ipmaxAsm, const Worker& worker, bool limitView, const View& view );
uint32_t CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view ); uint32_t CountAsmIpStats( uint64_t baseAddr, const Worker& worker, bool limitView, const View& view );
void SelectMicroArchitecture( const char* moniker ); void SelectMicroArchitecture( const char* moniker );