Store callstack frame module name.

This commit is contained in:
Bartosz Taudul 2020-02-26 00:32:47 +01:00
parent 4cf520db93
commit 7d0dac9ae2
2 changed files with 7 additions and 7 deletions

View File

@ -257,8 +257,10 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
si->SizeOfStruct = sizeof( SYMBOL_INFO ); si->SizeOfStruct = sizeof( SYMBOL_INFO );
si->MaxNameLen = 1024; si->MaxNameLen = 1024;
char moduleName[1024];
ULONG moduleNameLen;
GetModuleName( ptr, moduleName, moduleNameLen );
const auto symValid = SymFromAddr( proc, ptr, nullptr, si ) != 0; const auto symValid = SymFromAddr( proc, ptr, nullptr, si ) != 0;
if( !symValid ) GetModuleName( ptr, si->Name, si->NameLen );
IMAGEHLP_LINE64 line; IMAGEHLP_LINE64 line;
DWORD displacement = 0; DWORD displacement = 0;
@ -277,7 +279,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
cb_data[write].line = line.LineNumber; cb_data[write].line = line.LineNumber;
} }
cb_data[write].name = CopyString( si->Name, si->NameLen ); cb_data[write].name = symValid ? CopyString( si->Name, si->NameLen ) : CopyString( moduleName, moduleNameLen );
cb_data[write].file = CopyString( filename ); cb_data[write].file = CopyString( filename );
cb_data[write].symAddr = symValid ? si->Address : 0; cb_data[write].symAddr = symValid ? si->Address : 0;
} }
@ -288,10 +290,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
for( DWORD i=0; i<inlineNum; i++ ) for( DWORD i=0; i<inlineNum; i++ )
{ {
auto& cb = cb_data[i]; auto& cb = cb_data[i];
const auto symInlineValid = SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0; const auto symInlineValid = SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0;
if( !symInlineValid ) GetModuleName( ptr, si->Name, si->NameLen );
const char* filename; const char* filename;
if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 ) if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 )
{ {
@ -304,7 +303,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
cb.line = line.LineNumber; cb.line = line.LineNumber;
} }
cb.name = CopyString( si->Name, si->NameLen ); cb.name = symInlineValid ? CopyString( si->Name, si->NameLen ) : CopyString( moduleName, moduleNameLen );
cb.file = CopyString( filename ); cb.file = CopyString( filename );
cb.symAddr = symInlineValid ? si->Address : 0; cb.symAddr = symInlineValid ? si->Address : 0;
@ -313,7 +312,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
} }
#endif #endif
return { cb_data, uint8_t( cb_num ) }; return { cb_data, uint8_t( cb_num ), CopyString( moduleName, moduleNameLen ) };
} }
#elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6 #elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6

View File

@ -34,6 +34,7 @@ struct CallstackEntryData
{ {
const CallstackEntry* data; const CallstackEntry* data;
uint8_t size; uint8_t size;
const char* imageName;
}; };
const char* DecodeCallstackPtrFast( uint64_t ptr ); const char* DecodeCallstackPtrFast( uint64_t ptr );