From 66ef71cf7ba4ce56de8fa5726c2767f13448b3b9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 18 Apr 2021 21:09:20 +0200 Subject: [PATCH] Gather child IP stats for addresses without samples. --- server/TracySourceView.cpp | 57 ++++++++++++++++++++++++++++++++++++++ server/TracySourceView.hpp | 1 + 2 files changed, 58 insertions(+) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index afa5edb6..20b1bce1 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -1099,6 +1099,7 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view ) if( m_calcInlineStats ) { 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 { @@ -1113,6 +1114,7 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view ) iptr++; } } + GatherAdditionalIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view ); iptotalSrc = iptotalAsm; } 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& ipcountSrc, unordered_flat_map& 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 ) { if( limitView ) diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index dc68b27e..9f73d2ac 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -147,6 +147,7 @@ private: void SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker ); void GatherIpStats( uint64_t baseAddr, AddrStat& iptotalSrc, AddrStat& iptotalAsm, unordered_flat_map& ipcountSrc, unordered_flat_map& 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& ipcountSrc, unordered_flat_map& 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 ); void SelectMicroArchitecture( const char* moniker );