mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Only copy symbol strings, if needed.
This commit is contained in:
parent
2df6f9068a
commit
474383b656
@ -237,18 +237,17 @@ SymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
IMAGEHLP_LINE64 line;
|
||||
DWORD displacement = 0;
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
const char* filename;
|
||||
if( SymGetLineFromAddr64( GetCurrentProcess(), ptr, &displacement, &line ) == 0 )
|
||||
{
|
||||
filename = "[unknown]";
|
||||
sym.file = "[unknown]";
|
||||
sym.line = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = line.FileName;
|
||||
sym.file = line.FileName;
|
||||
sym.line = line.LineNumber;
|
||||
}
|
||||
sym.file = CopyString( filename );
|
||||
sym.needFree = false;
|
||||
return sym;
|
||||
}
|
||||
|
||||
@ -397,16 +396,18 @@ static int SymbolAddressDataCb( void* data, uintptr_t pc, const char* fn, int li
|
||||
if( !fn )
|
||||
{
|
||||
const char* symloc = nullptr;
|
||||
Dl_info dlinfo;
|
||||
static Dl_info dlinfo;
|
||||
if( dladdr( (void*)ptr, &dlinfo ) ) symloc = dlinfo.dli_fname;
|
||||
if( !symloc ) symloc = "[unknown]";
|
||||
sym.file = CopyString( symloc );
|
||||
sym.file = symloc;
|
||||
sym.line = 0;
|
||||
sym.needFree = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sym.file = CopyString( fn );
|
||||
sym.line = lineno;
|
||||
sym.needFree = true;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -597,10 +598,10 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
|
||||
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
{
|
||||
const char* symloc = nullptr;
|
||||
Dl_info dlinfo;
|
||||
static Dl_info dlinfo;
|
||||
if( dladdr( (void*)ptr, &dlinfo ) ) symloc = dlinfo.dli_fname;
|
||||
if( !symloc ) symloc = "[unknown]";
|
||||
return SymbolData { CopyString( symloc ), 0 };
|
||||
return SymbolData { symloc, 0, false };
|
||||
}
|
||||
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
|
@ -26,6 +26,7 @@ struct SymbolData
|
||||
{
|
||||
const char* file;
|
||||
uint32_t line;
|
||||
bool needFree;
|
||||
};
|
||||
|
||||
struct CallstackEntry
|
||||
|
@ -2695,7 +2695,7 @@ void Profiler::HandleSymbolQuery( uint64_t symbol )
|
||||
|
||||
AppendData( &item, QueueDataSize[(int)QueueType::SymbolInformation] );
|
||||
|
||||
tracy_free( (void*)sym.file );
|
||||
if( sym.needFree ) tracy_free( (void*)sym.file );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user