mirror of
https://github.com/wolfpld/tracy.git
synced 2026-11-19 22:25:59 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
734763c5aa
commit
56c9612137
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user