From fd55c1e975c25dab3397194fa3de89dc6cd655a0 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 1 May 2022 14:25:07 +0200 Subject: [PATCH] Pass symbol image name to CacheSource(). --- server/TracyWorker.cpp | 24 ++++++++++++++++++------ server/TracyWorker.hpp | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 8f139f45..7a1b1c32 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3371,7 +3371,7 @@ void Worker::QueryTerminate() m_sock.Send( &query, ServerQueryPacketSize ); } -void Worker::QuerySourceFile( const char* fn ) +void Worker::QuerySourceFile( const char* fn, const char* image ) { QueryDataTransfer( fn, strlen( fn ) + 1 ); Query( ServerQuerySourceCode, 0 ); @@ -6597,7 +6597,7 @@ void Worker::ProcessCallstackFrame( const QueueCallstackFrame& ev, bool querySym StringRef ref( StringRef::Idx, fitidx ); auto cit = m_checkedFileStrings.find( ref ); - if( cit == m_checkedFileStrings.end() ) CacheSource( ref ); + if( cit == m_checkedFileStrings.end() ) CacheSource( ref, m_callstackFrameStaging->imageName ); const auto frameId = PackPointer( m_callstackFrameStagingPtr ); #ifndef TRACY_NO_STATISTICS @@ -6700,7 +6700,7 @@ void Worker::ProcessSymbolInformation( const QueueSymbolInformation& ev ) StringRef ref( StringRef::Idx, idx ); auto cit = m_checkedFileStrings.find( ref ); - if( cit == m_checkedFileStrings.end() ) CacheSource( ref ); + if( cit == m_checkedFileStrings.end() ) CacheSource( ref, it->second.imageName ); m_pendingSymbols.erase( it ); } @@ -6733,7 +6733,19 @@ void Worker::ProcessCodeInformation( const QueueCodeInformation& ev ) StringRef ref( StringRef::Idx, idx ); auto cit = m_checkedFileStrings.find( ref ); - if( cit == m_checkedFileStrings.end() ) CacheSource( ref ); + if( cit == m_checkedFileStrings.end() ) + { + auto& symmap = GetSymbolMap(); + auto it = symmap.find( ev.symAddr ); + if( it == symmap.end() ) + { + CacheSource( ref ); + } + else + { + CacheSource( ref, it->second.imageName ); + } + } } if( ev.symAddr != 0 ) { @@ -8514,7 +8526,7 @@ ZoneExtra& Worker::RequestZoneExtra( ZoneEvent& ev ) } } -void Worker::CacheSource( const StringRef& str ) +void Worker::CacheSource( const StringRef& str, const StringIdx& image ) { assert( str.active ); assert( m_checkedFileStrings.find( str ) == m_checkedFileStrings.end() ); @@ -8530,7 +8542,7 @@ void Worker::CacheSource( const StringRef& str ) else if( execTime != 0 ) { m_sourceCodeQuery.emplace_back( file ); - QuerySourceFile( file ); + QuerySourceFile( file, image.Active() ? GetString( image ) : nullptr ); } } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 5b261a1b..0a3c8064 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -667,7 +667,7 @@ private: void Exec(); void Query( ServerQuery type, uint64_t data, uint32_t extra = 0 ); void QueryTerminate(); - void QuerySourceFile( const char* fn ); + void QuerySourceFile( const char* fn, const char* image ); void QueryDataTransfer( const void* ptr, size_t size ); tracy_force_inline bool DispatchProcess( const QueueItem& ev, const char*& ptr ); @@ -886,7 +886,7 @@ private: StringLocation StoreString( const char* str, size_t sz ); const ContextSwitch* const GetContextSwitchDataImpl( uint64_t thread ); - void CacheSource( const StringRef& str ); + void CacheSource( const StringRef& str, const StringIdx& image = StringIdx() ); void CacheSourceFromFile( const char* fn ); tracy_force_inline Vector>& GetZoneChildrenMutable( int32_t idx ) { return m_data.zoneChildren[idx]; }