diff --git a/public/common/TracyVersion.hpp b/public/common/TracyVersion.hpp index d7d900db..ac24e848 100644 --- a/public/common/TracyVersion.hpp +++ b/public/common/TracyVersion.hpp @@ -7,7 +7,7 @@ namespace Version { enum { Major = 0 }; enum { Minor = 8 }; -enum { Patch = 4 }; +enum { Patch = 5 }; } } diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 3451b034..dde7ce04 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -96,6 +96,11 @@ struct ChildStat }; +static tracy_force_inline uint64_t PackFileLine( uint32_t fileIdx, uint32_t line ) +{ + return ( uint64_t( fileIdx ) << 32 ) | line; +} + static size_t CountHwSamples( const SortedVector& vec, const Range& range ) { if( vec.empty() ) return 0; @@ -655,6 +660,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker ) m_locMap.clear(); m_jumpTable.clear(); m_jumpOut.clear(); + m_locationAddress.clear(); m_maxJumpLevel = 0; m_asmSelected = -1; m_asmCountBase = -1; @@ -936,9 +942,17 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker ) if( srcline > mLineMax ) mLineMax = srcline; const auto idx = srcidx.Idx(); auto sit = m_sourceFiles.find( idx ); - if( sit == m_sourceFiles.end() ) + if( sit == m_sourceFiles.end() ) m_sourceFiles.emplace( idx, srcline ); + const auto packed = PackFileLine( idx, srcline ); + auto lit = m_locationAddress.find( packed ); + if( lit == m_locationAddress.end() ) { - m_sourceFiles.emplace( idx, srcline ); + m_locationAddress.emplace( packed, std::vector( { op.address } ) ); + } + else + { + assert( lit->second.back() < op.address ); + lit->second.push_back( op.address ); } } char tmp[16]; @@ -2109,7 +2123,7 @@ void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker, { if( as.ipCountSrc.find( lineNum ) == as.ipCountSrc.end() ) { - auto addresses = worker.GetAddressesForLocation( m_source.idx(), lineNum ); + auto addresses = GetAddressesForLocation( m_source.idx(), lineNum ); if( addresses ) { for( auto& addr : *addresses ) @@ -3076,7 +3090,7 @@ void SourceView::RenderLine( const Tokenizer::Line& line, int lineNum, const Add if( !m_asm.empty() ) { assert( worker && view ); - auto addresses = worker->GetAddressesForLocation( m_source.idx(), lineNum ); + auto addresses = GetAddressesForLocation( m_source.idx(), lineNum ); if( addresses ) { for( auto& addr : *addresses ) @@ -4678,7 +4692,7 @@ void SourceView::SelectLine( uint32_t line, const Worker* worker, bool updateAsm void SourceView::SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool updateAsmLine, uint64_t targetAddr, bool changeAsmLine ) { m_selectedAddresses.clear(); - auto addresses = worker.GetAddressesForLocation( file, line ); + auto addresses = GetAddressesForLocation( file, line ); if( addresses ) { const auto& addr = *addresses; @@ -4736,7 +4750,7 @@ void SourceView::SelectAsmLines( uint32_t file, uint32_t line, const Worker& wor void SourceView::SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker ) { assert( m_selectedAddressesHover.empty() ); - auto addresses = worker.GetAddressesForLocation( file, line ); + auto addresses = GetAddressesForLocation( file, line ); if( addresses ) { for( auto& v : *addresses ) @@ -5391,6 +5405,19 @@ bool SourceView::IsInContext( const Worker& worker, uint64_t addr ) const return !m_calcInlineStats || !worker.HasInlineSymbolAddresses() || worker.GetInlineSymbolForAddress( addr ) == m_symAddr; } +const std::vector* SourceView::GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line ) const +{ + auto it = m_locationAddress.find( PackFileLine( fileStringIdx, line ) ); + if( it == m_locationAddress.end() ) + { + return nullptr; + } + else + { + return &it->second; + } +} + #ifndef TRACY_NO_FILESELECTOR void SourceView::Save( const Worker& worker, size_t start, size_t stop ) { diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index b18853a4..17f95df6 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -202,6 +202,7 @@ private: void CheckWrite( size_t line, RegsX86 reg, size_t limit ); bool IsInContext( const Worker& worker, uint64_t addr ) const; + const std::vector* GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line ) const; #ifndef TRACY_NO_FILESELECTOR void Save( const Worker& worker, size_t start = 0, size_t stop = std::numeric_limits::max() ); @@ -249,6 +250,8 @@ private: size_t m_maxJumpLevel; bool m_showJumps; + unordered_flat_map> m_locationAddress; + unordered_flat_map m_sourceFiles; unordered_flat_set m_selectedAddresses; unordered_flat_set m_selectedAddressesHover; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index cda534e7..8c8bc274 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -38,11 +38,6 @@ namespace tracy { -static tracy_force_inline uint64_t PackFileLine( uint32_t fileIdx, uint32_t line ) -{ - return ( uint64_t( fileIdx ) << 32 ) | line; -} - static tracy_force_inline uint32_t UnpackFileLine( uint64_t packed, uint32_t& line ) { line = packed & 0xFFFFFFFF; @@ -1772,31 +1767,9 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) } } - f.Read( sz ); - if( eventMask & EventType::SymbolCode ) - { - m_data.locationCodeAddressList.reserve( sz ); - for( uint64_t i=0; i data; - data.reserve_exact( lsz, m_slab ); - uint64_t ref = 0; - for( uint16_t j=0; j* Worker::GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line ) const -{ - auto it = m_data.locationCodeAddressList.find( PackFileLine( fileStringIdx, line ) ); - if( it == m_data.locationCodeAddressList.end() ) - { - return nullptr; - } - else - { - return &it->second; - } -} - const uint64_t* Worker::GetInlineSymbolList( uint64_t sym, uint32_t len ) { DoPostponedInlineSymbols(); @@ -8401,23 +8361,6 @@ void Worker::Write( FileWrite& f, bool fiDict ) f.Write( v.second.data, v.second.len ); } - sz = m_data.locationCodeAddressList.size(); - f.Write( &sz, sizeof( sz ) ); - for( auto& v : m_data.locationCodeAddressList ) - { - f.Write( &v.first, sizeof( v.first ) ); - uint16_t lsz = uint16_t( v.second.size() ); - f.Write( &lsz, sizeof( lsz ) ); - uint64_t ref = 0; - const uint64_t* ptr = v.second.data(); - for( uint16_t i=0; i codeAddressToLocation; - unordered_flat_map> locationCodeAddressList; unordered_flat_map sourceFileCache; @@ -546,7 +545,6 @@ public: uint64_t GetInlineSymbolForAddress( uint64_t address ) const; bool HasInlineSymbolAddresses() const { return !m_data.codeSymbolMap.empty(); } StringIdx GetLocationForAddress( uint64_t address, uint32_t& line ) const; - const Vector* GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line ) const; const uint64_t* GetInlineSymbolList( uint64_t sym, uint32_t len ); #ifndef TRACY_NO_STATISTICS