From cf33cbd33fc0f2780ef39ba90fe7e22c826767df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Mon, 30 Mar 2026 18:41:54 +0200 Subject: [PATCH 1/4] Extract MakeUnresolvedCallstackEntryData --- public/client/TracyCallstack.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index 7688eab2..431cac89 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -734,6 +734,18 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr ) return sym; } +static CallstackEntryData MakeUnresolvedCallstackEntryData( uint64_t ptr, ModuleNameAndBaseAddress moduleNameAndBaseAddress ) +{ + cb_data[0].symAddr = ptr - moduleNameAndBaseAddress.baseAddr; + cb_data[0].symLen = 0; + + cb_data[0].name = CopyStringFast( "[unresolved]" ); + cb_data[0].file = CopyStringFast( "[unknown]" ); + cb_data[0].line = 0; + + return { cb_data, 1, moduleNameAndBaseAddress.name }; +} + CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) { #ifdef TRACY_DBGHELP_LOCK @@ -749,15 +761,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) #ifdef TRACY_DBGHELP_LOCK DBGHELP_UNLOCK; #endif - - cb_data[0].symAddr = ptr - moduleNameAndAddress.baseAddr; - cb_data[0].symLen = 0; - - cb_data[0].name = CopyStringFast("[unresolved]"); - cb_data[0].file = CopyStringFast("[unknown]"); - cb_data[0].line = 0; - - return { cb_data, 1, moduleNameAndAddress.name }; + return MakeUnresolvedCallstackEntryData( ptr, moduleNameAndAddress ); } int write; From 8c5724d12563013b508b8c6c9b77a64a49037e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Mon, 30 Mar 2026 22:07:50 +0200 Subject: [PATCH 2/4] Fix formating in DbgHelpInit --- public/client/TracyCallstack.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index 431cac89..d693d579 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -411,28 +411,30 @@ void DbgHelpInit() // append executable path to the _NT_SYMBOL_PATH environment variable char buffer [32767]; // max env var length on Windows (including null-terminator) DWORD length = GetEnvironmentVariableA( "_NT_SYMBOL_PATH", buffer, sizeof( buffer ) ); - if( length > sizeof( buffer ) ) { - SymError( "GetEnvironmentVariableA", GetLastError() ); - } else if( length + 1 >= sizeof( buffer ) ) { - SymError( "_TracyAppendEnvironmentVariable", ERROR_INSUFFICIENT_BUFFER ); - } else { + if( length > sizeof( buffer ) ) SymError( "GetEnvironmentVariableA", GetLastError() ); + else if( length + 1 >= sizeof( buffer ) ) SymError( "_TracyAppendEnvironmentVariable", ERROR_INSUFFICIENT_BUFFER ); + else + { buffer[length] = ';'; buffer[++length] = '\0'; length += GetModuleFileNameA( NULL, &buffer[length], sizeof( buffer ) - length ); - if( length >= sizeof( buffer ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER ) { + if( length >= sizeof( buffer ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER ) + { SymError( "GetModuleFileNameA", GetLastError() ); - } else { + } + else + { while( length > 0 && buffer[--length] != '\\' ) buffer[length] = '\0'; } } - assert( length < sizeof( buffer ) ); - if( SetEnvironmentVariableA( "_NT_SYMBOL_PATH", buffer ) == FALSE ) { - SymError( "SetEnvironmentVariableA", GetLastError() ); - } + assert( length < sizeof( buffer ) ); + if( SetEnvironmentVariableA( "_NT_SYMBOL_PATH", buffer ) == FALSE ) SymError( "SetEnvironmentVariableA", GetLastError() ); + SymSetOptions( SymGetOptions() | SYMOPT_LOAD_LINES ); - if( SymInitialize( GetCurrentProcess(), NULL, TRUE ) == FALSE ) { + if( SymInitialize( GetCurrentProcess(), NULL, TRUE ) == FALSE ) + { SymError( "SymInitialize", GetLastError() ); } From 79f7d99b0258c383606187ef4c0b9196158178fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Mon, 30 Mar 2026 22:09:14 +0200 Subject: [PATCH 3/4] Add SymSrv.dll check This is often a source of missing symbols or incomprehension as to why they are not getting resolved. Having a debug log will help debugging such cases. --- public/client/TracyCallstack.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index d693d579..af912569 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -437,6 +437,11 @@ void DbgHelpInit() { SymError( "SymInitialize", GetLastError() ); } + else if( GetModuleHandleA( "SymSrv.dll" ) == NULL ) + { + TracyDebug( "SymSrv.dll was not loaded, it needs to be near a matching version of DbgHelp.dll. Symbol resolution may fail as symbol servers will not be used. See https://learn.microsoft.com/en-us/windows/win32/debug/calling-the-dbghelp-library" ); + } + #ifdef TRACY_DBGHELP_LOCK DBGHELP_UNLOCK; From da4b95bf59deaa929583219c65e08fe68c4900c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gr=C3=A9goire?= Date: Mon, 30 Mar 2026 22:24:20 +0200 Subject: [PATCH 4/4] Use CopyString(Fast) where possible in TracyCallstack --- public/client/TracyCallstack.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index af912569..4cfbbca7 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -279,9 +279,7 @@ private: { if( dlInfo.dli_fname ) { - size_t sz = strlen( dlInfo.dli_fname ) + 1; - entry.m_name = (char*)tracy_malloc( sz ); - memcpy( entry.m_name, dlInfo.dli_fname, sz ); + entry.name = CopyString( dlInfo.dli_fname ); } } @@ -978,15 +976,11 @@ static void InitKernelSymbols() { validCnt++; - strname = (char*)tracy_malloc_fast( nameend - namestart + 1 ); - memcpy( strname, namestart, nameend - namestart ); - strname[nameend-namestart] = '\0'; + strname = CopyStringFast( namestart, nameend - namestart ); if( modstart ) { - strmod = (char*)tracy_malloc_fast( modend - modstart + 1 ); - memcpy( strmod, modstart, modend - modstart ); - strmod[modend-modstart] = '\0'; + strmod = CopyStringFast( modstart, modend - modstart ); } }