From 56c961213713cb5a27ad73ef7537db109c2e57bb Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Wed, 18 Nov 2026 13:29:21 +0000 Subject: [PATCH] Keep the dladdr symbol address for frames libbacktrace can't resolve. When libbacktrace has no debug info for a pc, CallstackDataCb names the frame from dladdr but keeps libbacktrace's lowaddr, which is 0 there, as its symbol address, and SymInfoCallback then overwrites it with libbacktrace's symval, also 0, since libbacktrace has no symbol for it either. Every such frame (on macOS, every frame in a system library) gets symbol address 0, so the sampling statistics count all of them as one symbol with no name. Record dli_saddr as the frame's symbol address, as the dladdr-only DecodeCallstackPtr (TRACY_HAS_CALLSTACK 5) does, and have SymInfoCallback keep the address CallstackDataCb found when libbacktrace reports no symbol. Co-Authored-By: Claude Opus 5.5 --- public/client/TracyCallstack.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index 4c563a47..f2980c7c 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -1784,6 +1784,7 @@ static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, con { symname = dlinfo.dli_sname; symoff = (char*)pc - (char*)dlinfo.dli_saddr; + if( dlinfo.dli_saddr ) cb_data[cb_num].symAddr = (uint64_t)dlinfo.dli_saddr; const char* demangled = ___tracy_demangle( symname ); if( demangled ) symname = demangled; } @@ -1857,6 +1858,9 @@ static void CallstackErrorCb( void* /*data*/, const char* /*msg*/, int /*errnum* void SymInfoCallback( void* /*data*/, uintptr_t pc, const char* symname, uintptr_t symval, uintptr_t symsize ) { + // libbacktrace reports a pc it has no symbol for with a null name and a zero value; keep the address + // CallstackDataCb found for the frame (its dladdr fallback finds one in a library libbacktrace can't read). + if( !symname ) return; cb_data[cb_num-1].symLen = (uint32_t)symsize; cb_data[cb_num-1].symAddr = (uint64_t)symval; }