mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Add time range limiting to symbol view.
This commit is contained in:
parent
7a4ecc5417
commit
5dd7c7e402
@ -1115,23 +1115,24 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view )
|
||||
TextFocused( ICON_FA_WEIGHT_HANGING " Code size:", MemSizeToString( m_codeLen ) );
|
||||
}
|
||||
|
||||
const bool limitView = view.m_statRange.active;
|
||||
uint32_t iptotalSrc = 0, iptotalAsm = 0;
|
||||
uint32_t ipmaxSrc = 0, ipmaxAsm = 0;
|
||||
unordered_flat_map<uint64_t, uint32_t> ipcountSrc, ipcountAsm;
|
||||
if( m_calcInlineStats )
|
||||
{
|
||||
GatherIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker );
|
||||
GatherIpStats( m_symAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
|
||||
}
|
||||
else
|
||||
{
|
||||
GatherIpStats( m_baseAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker );
|
||||
GatherIpStats( m_baseAddr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
|
||||
auto iptr = worker.GetInlineSymbolList( m_baseAddr, m_codeLen );
|
||||
if( iptr )
|
||||
{
|
||||
const auto symEnd = m_baseAddr + m_codeLen;
|
||||
while( *iptr < symEnd )
|
||||
{
|
||||
GatherIpStats( *iptr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker );
|
||||
GatherIpStats( *iptr, iptotalSrc, iptotalAsm, ipcountSrc, ipcountAsm, ipmaxSrc, ipmaxAsm, worker, limitView, view );
|
||||
iptr++;
|
||||
}
|
||||
}
|
||||
@ -3060,8 +3061,63 @@ void SourceView::SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker
|
||||
}
|
||||
}
|
||||
|
||||
void SourceView::GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& iptotalAsm, unordered_flat_map<uint64_t, uint32_t>& ipcountSrc, unordered_flat_map<uint64_t, uint32_t>& ipcountAsm, uint32_t& ipmaxSrc, uint32_t& ipmaxAsm, const Worker& worker )
|
||||
void SourceView::GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& iptotalAsm, unordered_flat_map<uint64_t, uint32_t>& ipcountSrc, unordered_flat_map<uint64_t, uint32_t>& ipcountAsm, uint32_t& ipmaxSrc, uint32_t& ipmaxAsm, const Worker& worker, bool limitView, const View& view )
|
||||
{
|
||||
if( limitView )
|
||||
{
|
||||
auto vec = worker.GetSamplesForSymbol( addr );
|
||||
if( !vec ) return;
|
||||
auto it = std::lower_bound( vec->begin(), vec->end(), view.m_statRange.min, [] ( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs; } );
|
||||
if( it == vec->end() ) return;
|
||||
auto end = std::lower_bound( it, vec->end(), view.m_statRange.max, [] ( const auto& lhs, const auto& rhs ) { return lhs.time.Val() < rhs; } );
|
||||
iptotalAsm += end - it;
|
||||
while( it != end )
|
||||
{
|
||||
if( m_file )
|
||||
{
|
||||
auto frame = worker.GetCallstackFrame( it->ip );
|
||||
if( frame )
|
||||
{
|
||||
auto ffn = worker.GetString( frame->data[0].file );
|
||||
if( strcmp( ffn, m_file ) == 0 )
|
||||
{
|
||||
const auto line = frame->data[0].line;
|
||||
auto sit = ipcountSrc.find( line );
|
||||
if( sit == ipcountSrc.end() )
|
||||
{
|
||||
ipcountSrc.emplace( line, 1 );
|
||||
if( ipmaxSrc < 1 ) ipmaxSrc = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto sum = sit->second + 1;
|
||||
sit->second = sum;
|
||||
if( ipmaxSrc < sum ) ipmaxSrc = sum;
|
||||
}
|
||||
iptotalSrc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto addr = worker.GetCanonicalPointer( it->ip );
|
||||
auto sit = ipcountAsm.find( addr );
|
||||
if( sit == ipcountAsm.end() )
|
||||
{
|
||||
ipcountAsm.emplace( addr, 1 );
|
||||
if( ipmaxAsm < 1 ) ipmaxAsm = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto sum = sit->second + 1;
|
||||
sit->second = sum;
|
||||
if( ipmaxAsm < sum ) ipmaxAsm = sum;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ipmap = worker.GetSymbolInstructionPointers( addr );
|
||||
if( !ipmap ) return;
|
||||
for( auto& ip : *ipmap )
|
||||
@ -3098,6 +3154,7 @@ void SourceView::GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& i
|
||||
iptotalAsm += ip.second;
|
||||
if( ipmaxAsm < ip.second ) ipmaxAsm = ip.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -157,7 +157,7 @@ private:
|
||||
void SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
|
||||
void SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker );
|
||||
|
||||
void GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& iptotalAsm, unordered_flat_map<uint64_t, uint32_t>& ipcountSrc, unordered_flat_map<uint64_t, uint32_t>& ipcountAsm, uint32_t& ipmaxSrc, uint32_t& ipmaxAsm, const Worker& worker );
|
||||
void GatherIpStats( uint64_t addr, uint32_t& iptotalSrc, uint32_t& iptotalAsm, unordered_flat_map<uint64_t, uint32_t>& ipcountSrc, unordered_flat_map<uint64_t, uint32_t>& ipcountAsm, uint32_t& ipmaxSrc, uint32_t& ipmaxAsm, const Worker& worker, bool limitView, const View& view );
|
||||
|
||||
void SelectMicroArchitecture( const char* moniker );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user