From ee13d3fa44e1a5e98402ff9a62800fd34b14bb5c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 19 Jun 2021 19:51:20 +0200 Subject: [PATCH] Retrieve address of symbol, not first instruction in line. --- client/TracyCallstack.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 6c40d586..c3d16934 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -376,6 +376,11 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr ) const auto proc = GetCurrentProcess(); bool done = false; + char buf[sizeof( SYMBOL_INFO ) + MaxNameSize]; + auto si = (SYMBOL_INFO*)buf; + si->SizeOfStruct = sizeof( SYMBOL_INFO ); + si->MaxNameLen = MaxNameSize; + IMAGEHLP_LINE64 line; DWORD displacement = 0; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); @@ -397,8 +402,16 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr ) { sym.file = line.FileName; sym.line = line.LineNumber; - sym.symAddr = line.Address; done = true; + + if( _SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0 ) + { + sym.symAddr = si->Address; + } + else + { + sym.symAddr = 0; + } } } } @@ -415,7 +428,15 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr ) { sym.file = line.FileName; sym.line = line.LineNumber; - sym.symAddr = line.Address; + + if( SymFromAddr( proc, ptr, nullptr, si ) != 0 ) + { + sym.symAddr = si->Address; + } + else + { + sym.symAddr = 0; + } } } #ifdef TRACY_DBGHELP_LOCK