From 5ab84d0c3f26b7d381ec0e44282f97499ace59d4 Mon Sep 17 00:00:00 2001 From: Kevin Kuehler Date: Fri, 21 May 2021 15:25:26 -0700 Subject: [PATCH] Use file:line when comparing traces When comparing traces, where multiple classes share the same zone names, the behavior prior to this patch was to auto-select the first matching zone name in the other trace. Instead, find the most correct zone by using filename and line number. --- server/TracyView.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index fc10ddea..2e0e4ff6 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -11407,8 +11407,10 @@ void View::DrawCompare() auto& srcloc1 = m_compare.second->GetSourceLocation( m_compare.match[1][m_compare.selMatch[1]] ); auto string0 = m_worker.GetString( srcloc0.name.active ? srcloc0.name : srcloc0.function ); auto string1 = m_compare.second->GetString( srcloc1.name.active ? srcloc1.name : srcloc1.function ); + auto file0 = m_worker.GetString( srcloc0.file ); + auto file1 = m_compare.second->GetString( srcloc1.file ); - if( strcmp( string0, string1 ) != 0 ) + if( strcmp( string0, string1 ) != 0 || strcmp( file0, file1 ) != 0 || srcloc0.line != srcloc1.line ) { idx = 0; if( prev0 != m_compare.selMatch[0] ) @@ -11417,7 +11419,8 @@ void View::DrawCompare() { auto& srcloc = m_compare.second->GetSourceLocation( v ); auto string = m_compare.second->GetString( srcloc.name.active ? srcloc.name : srcloc.function ); - if( strcmp( string0, string ) == 0 ) + auto file = m_compare.second->GetString( srcloc.file ); + if( strcmp( string0, string ) == 0 && strcmp( file0, file) == 0 && srcloc0.line == srcloc.line ) { m_compare.selMatch[1] = idx; break; @@ -11432,7 +11435,8 @@ void View::DrawCompare() { auto& srcloc = m_worker.GetSourceLocation( v ); auto string = m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ); - if( strcmp( string1, string ) == 0 ) + auto file = m_compare.second->GetString( srcloc.file ); + if( strcmp( string1, string ) == 0 && strcmp( file1, file) == 0 && srcloc1.line == srcloc.line ) { m_compare.selMatch[0] = idx; break;