diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index d6bec3a4..03794ad0 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -239,6 +239,49 @@ SymbolData DecodeSymbolAddress( uint64_t ptr ) return sym; } +SymbolData DecodeCodeAddress( uint64_t ptr ) +{ + SymbolData sym; + const auto proc = GetCurrentProcess(); + bool done = false; + + IMAGEHLP_LINE64 line; + DWORD displacement = 0; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + +#ifndef __CYGWIN__ + DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr ); + DWORD ctx = 0; + DWORD idx; + BOOL doInline = FALSE; + if( inlineNum != 0 ) doInline = SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx ); + if( doInline ) + { + if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) != 0 ) + { + sym.file = line.FileName; + sym.line = line.LineNumber; + done = true; + } + } +#endif + if( !done ) + { + if( SymGetLineFromAddr64( proc, ptr, &displacement, &line ) == 0 ) + { + sym.file = "[unknown]"; + sym.line = 0; + } + else + { + sym.file = line.FileName; + sym.line = line.LineNumber; + } + } + sym.needFree = false; + return sym; +} + CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) { int write; @@ -429,6 +472,11 @@ SymbolData DecodeSymbolAddress( uint64_t ptr ) return sym; } +SymbolData DecodeCodeAddress( uint64_t ptr ) +{ + return DecodeSymbolAddress( ptr ); +} + static int CallstackDataCb( void* /*data*/, uintptr_t pc, const char* fn, int lineno, const char* function ) { enum { DemangleBufLen = 64*1024 }; @@ -611,6 +659,11 @@ SymbolData DecodeSymbolAddress( uint64_t ptr ) return SymbolData { symloc, 0, false }; } +SymbolData DecodeCodeAddress( uint64_t ptr ) +{ + return DecodeSymbolAddress( ptr ); +} + CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) { static CallstackEntry cb; diff --git a/client/TracyCallstack.hpp b/client/TracyCallstack.hpp index 1932a708..c5c2059a 100644 --- a/client/TracyCallstack.hpp +++ b/client/TracyCallstack.hpp @@ -46,6 +46,7 @@ struct CallstackEntryData }; SymbolData DecodeSymbolAddress( uint64_t ptr ); +SymbolData DecodeCodeAddress( uint64_t ptr ); const char* DecodeCallstackPtrFast( uint64_t ptr ); CallstackEntryData DecodeCallstackPtr( uint64_t ptr ); void InitCallstack();