mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Don't retrieve symbol name for address.
This commit is contained in:
parent
be5793987e
commit
2df6f9068a
@ -234,20 +234,11 @@ static void GetModuleName( uint64_t addr, char* buf, ULONG& len )
|
|||||||
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||||
{
|
{
|
||||||
SymbolData sym;
|
SymbolData sym;
|
||||||
const auto proc = GetCurrentProcess();
|
|
||||||
|
|
||||||
char buf[sizeof( SYMBOL_INFO ) + MaxNameSize];
|
|
||||||
auto si = (SYMBOL_INFO*)buf;
|
|
||||||
si->SizeOfStruct = sizeof( SYMBOL_INFO );
|
|
||||||
si->MaxNameLen = MaxNameSize;
|
|
||||||
const auto symValid = SymFromAddr( proc, ptr, nullptr, si ) != 0;
|
|
||||||
|
|
||||||
IMAGEHLP_LINE64 line;
|
IMAGEHLP_LINE64 line;
|
||||||
DWORD displacement = 0;
|
DWORD displacement = 0;
|
||||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||||
|
|
||||||
const char* filename;
|
const char* filename;
|
||||||
if (SymGetLineFromAddr64(proc, ptr, &displacement, &line) == 0)
|
if( SymGetLineFromAddr64( GetCurrentProcess(), ptr, &displacement, &line ) == 0 )
|
||||||
{
|
{
|
||||||
filename = "[unknown]";
|
filename = "[unknown]";
|
||||||
sym.line = 0;
|
sym.line = 0;
|
||||||
@ -257,10 +248,7 @@ SymbolData DecodeSymbolAddress( uint64_t ptr )
|
|||||||
filename = line.FileName;
|
filename = line.FileName;
|
||||||
sym.line = line.LineNumber;
|
sym.line = line.LineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
sym.name = symValid ? CopyString( si->Name, si->NameLen ) : CopyString( "[unknown]", 9 );
|
|
||||||
sym.file = CopyString( filename );
|
sym.file = CopyString( filename );
|
||||||
|
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,63 +394,17 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
|
|||||||
static int SymbolAddressDataCb( void* data, uintptr_t pc, const char* fn, int lineno, const char* function )
|
static int SymbolAddressDataCb( void* data, uintptr_t pc, const char* fn, int lineno, const char* function )
|
||||||
{
|
{
|
||||||
auto& sym = *(SymbolData*)data;
|
auto& sym = *(SymbolData*)data;
|
||||||
|
if( !fn )
|
||||||
enum { DemangleBufLen = 64*1024 };
|
|
||||||
char demangled[DemangleBufLen];
|
|
||||||
|
|
||||||
if( !fn && !function )
|
|
||||||
{
|
{
|
||||||
const char* symname = nullptr;
|
|
||||||
const char* symloc = nullptr;
|
const char* symloc = nullptr;
|
||||||
auto vptr = (void*)pc;
|
|
||||||
|
|
||||||
Dl_info dlinfo;
|
Dl_info dlinfo;
|
||||||
if( dladdr( vptr, &dlinfo ) )
|
if( dladdr( (void*)ptr, &dlinfo ) ) symloc = dlinfo.dli_fname;
|
||||||
{
|
|
||||||
symloc = dlinfo.dli_fname;
|
|
||||||
symname = dlinfo.dli_sname;
|
|
||||||
|
|
||||||
if( symname && symname[0] == '_' )
|
|
||||||
{
|
|
||||||
size_t len = DemangleBufLen;
|
|
||||||
int status;
|
|
||||||
abi::__cxa_demangle( symname, demangled, &len, &status );
|
|
||||||
if( status == 0 )
|
|
||||||
{
|
|
||||||
symname = demangled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !symname ) symname = "[unknown]";
|
|
||||||
if( !symloc ) symloc = "[unknown]";
|
if( !symloc ) symloc = "[unknown]";
|
||||||
|
|
||||||
sym.name = CopyString( symname );
|
|
||||||
sym.file = CopyString( symloc );
|
sym.file = CopyString( symloc );
|
||||||
sym.line = 0;
|
sym.line = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !fn ) fn = "[unknown]";
|
|
||||||
if( !function )
|
|
||||||
{
|
|
||||||
function = "[unknown]";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( function[0] == '_' )
|
|
||||||
{
|
|
||||||
size_t len = DemangleBufLen;
|
|
||||||
int status;
|
|
||||||
abi::__cxa_demangle( function, demangled, &len, &status );
|
|
||||||
if( status == 0 )
|
|
||||||
{
|
|
||||||
function = demangled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sym.name = CopyString( function );
|
|
||||||
sym.file = CopyString( fn );
|
sym.file = CopyString( fn );
|
||||||
sym.line = lineno;
|
sym.line = lineno;
|
||||||
}
|
}
|
||||||
@ -654,47 +596,11 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
|
|||||||
|
|
||||||
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||||
{
|
{
|
||||||
SymbolData sym;
|
|
||||||
|
|
||||||
char* demangled = nullptr;
|
|
||||||
const char* symname = nullptr;
|
|
||||||
const char* symloc = nullptr;
|
const char* symloc = nullptr;
|
||||||
auto vptr = (void*)ptr;
|
|
||||||
|
|
||||||
Dl_info dlinfo;
|
Dl_info dlinfo;
|
||||||
if( dladdr( vptr, &dlinfo ) )
|
if( dladdr( (void*)ptr, &dlinfo ) ) symloc = dlinfo.dli_fname;
|
||||||
{
|
if( !symloc ) symloc = "[unknown]";
|
||||||
symloc = dlinfo.dli_fname;
|
return SymbolData { CopyString( symloc ), 0 };
|
||||||
symname = dlinfo.dli_sname;
|
|
||||||
|
|
||||||
if( symname && symname[0] == '_' )
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
int status;
|
|
||||||
demangled = abi::__cxa_demangle( symname, nullptr, &len, &status );
|
|
||||||
if( status == 0 )
|
|
||||||
{
|
|
||||||
symname = demangled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !symname )
|
|
||||||
{
|
|
||||||
symname = "[unknown]";
|
|
||||||
}
|
|
||||||
if( !symloc )
|
|
||||||
{
|
|
||||||
symloc = "[unknown]";
|
|
||||||
}
|
|
||||||
|
|
||||||
sym.name = CopyString( symname );
|
|
||||||
sym.file = CopyString( symloc );
|
|
||||||
sym.line = 0;
|
|
||||||
|
|
||||||
if( demangled ) free( demangled );
|
|
||||||
|
|
||||||
return sym;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||||
|
@ -24,13 +24,15 @@ namespace tracy
|
|||||||
|
|
||||||
struct SymbolData
|
struct SymbolData
|
||||||
{
|
{
|
||||||
const char* name;
|
|
||||||
const char* file;
|
const char* file;
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CallstackEntry : public SymbolData
|
struct CallstackEntry
|
||||||
{
|
{
|
||||||
|
const char* name;
|
||||||
|
const char* file;
|
||||||
|
uint32_t line;
|
||||||
uint64_t symAddr;
|
uint64_t symAddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2686,7 +2686,6 @@ void Profiler::HandleSymbolQuery( uint64_t symbol )
|
|||||||
const auto sym = DecodeSymbolAddress( symbol );
|
const auto sym = DecodeSymbolAddress( symbol );
|
||||||
|
|
||||||
SendString( uint64_t( sym.file ), sym.file, QueueType::CustomStringData );
|
SendString( uint64_t( sym.file ), sym.file, QueueType::CustomStringData );
|
||||||
SendString( uint64_t( sym.name ), sym.name, QueueType::CustomStringData );
|
|
||||||
|
|
||||||
QueueItem item;
|
QueueItem item;
|
||||||
MemWrite( &item.hdr.type, QueueType::SymbolInformation );
|
MemWrite( &item.hdr.type, QueueType::SymbolInformation );
|
||||||
@ -2697,7 +2696,6 @@ void Profiler::HandleSymbolQuery( uint64_t symbol )
|
|||||||
AppendData( &item, QueueDataSize[(int)QueueType::SymbolInformation] );
|
AppendData( &item, QueueDataSize[(int)QueueType::SymbolInformation] );
|
||||||
|
|
||||||
tracy_free( (void*)sym.file );
|
tracy_free( (void*)sym.file );
|
||||||
tracy_free( (void*)sym.name );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user