From 1967f2c79bbb78007484368c43aea3bff3b0bd7a Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 22 Mar 2026 16:51:55 +0100 Subject: [PATCH] Do proper frame matching instead of relying just on callstack size. --- profiler/src/profiler/TracyView_Utility.cpp | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/profiler/src/profiler/TracyView_Utility.cpp b/profiler/src/profiler/TracyView_Utility.cpp index fe6c4d77..c048a688 100644 --- a/profiler/src/profiler/TracyView_Utility.cpp +++ b/profiler/src/profiler/TracyView_Utility.cpp @@ -1069,6 +1069,41 @@ std::vector View::ReconstructZoneCallstack( const ZoneEvent& e auto& cs = m_worker.GetCallstack( *sit ); auto sz = cs.size(); if( ret.size() > sz ) ret.erase( ret.begin(), ret.end() - sz ); + if( ret.size() == 0 ) return ret; + + auto offset = std::max( size_t( 0 ), sz - ret.size() ); + size_t match = 0; + for( int i = ret.size() - 1; i >= 0; i-- ) + { + if( ret[i] == cs[i + offset] ) + { + match++; + } + else + { + auto fd1 = m_worker.GetCallstackFrame( ret[i] ); + auto fd2 = m_worker.GetCallstackFrame( cs[i + offset] ); + if( fd1 && fd2 ) + { + auto& f1 = fd1->data[fd1->size - 1]; + auto& f2 = fd2->data[fd2->size - 1]; + auto name1 = m_worker.GetString( f1.name ); + auto name2 = m_worker.GetString( f2.name ); + if( name1 == name2 || strcmp( name1, name2 ) == 0 ) + { + auto file1 = m_worker.GetString( f1.file ); + auto file2 = m_worker.GetString( f2.file ); + if( file1 == file2 || strcmp( file1, file2 ) == 0 ) + { + match++; + } + } + } + break; + } + } + + if( match != ret.size() ) ret.erase( ret.begin(), ret.end() - match ); } return ret;