Don't use image name as a replacement for source file.

Image name is now reported separately.
This commit is contained in:
Bartosz Taudul 2020-08-18 20:34:11 +02:00
parent 9ba7381030
commit 818d20d273

View File

@ -445,11 +445,7 @@ static int SymbolAddressDataCb( void* data, uintptr_t pc, uintptr_t lowaddr, con
auto& sym = *(SymbolData*)data; auto& sym = *(SymbolData*)data;
if( !fn ) if( !fn )
{ {
const char* symloc = nullptr; sym.file = "[unknown]";
Dl_info dlinfo;
if( dladdr( (void*)pc, &dlinfo ) ) symloc = dlinfo.dli_fname;
if( !symloc ) symloc = "[unknown]";
sym.file = symloc;
sym.line = 0; sym.line = 0;
sym.needFree = false; sym.needFree = false;
} }
@ -494,14 +490,12 @@ static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, con
if( !fn && !function ) if( !fn && !function )
{ {
const char* symname = nullptr; const char* symname = nullptr;
const char* symloc = nullptr;
auto vptr = (void*)pc; auto vptr = (void*)pc;
ptrdiff_t symoff = 0; ptrdiff_t symoff = 0;
Dl_info dlinfo; Dl_info dlinfo;
if( dladdr( vptr, &dlinfo ) ) if( dladdr( vptr, &dlinfo ) )
{ {
symloc = dlinfo.dli_fname;
symname = dlinfo.dli_sname; symname = dlinfo.dli_sname;
symoff = (char*)pc - (char*)dlinfo.dli_saddr; symoff = (char*)pc - (char*)dlinfo.dli_saddr;
@ -518,7 +512,6 @@ static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, con
} }
if( !symname ) symname = "[unknown]"; if( !symname ) symname = "[unknown]";
if( !symloc ) symloc = "[unknown]";
if( symoff == 0 ) if( symoff == 0 )
{ {
@ -536,15 +529,7 @@ static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, con
cb_data[cb_num].name = name; cb_data[cb_num].name = name;
} }
char buf[32]; cb_data[cb_num].file = CopyString( "[unknown]" );
const auto addrlen = sprintf( buf, " [%p]", (void*)pc );
const auto loclen = strlen( symloc );
auto loc = (char*)tracy_malloc( loclen + addrlen + 1 );
memcpy( loc, symloc, loclen );
memcpy( loc + loclen, buf, addrlen );
loc[loclen + addrlen] = '\0';
cb_data[cb_num].file = loc;
cb_data[cb_num].line = 0; cb_data[cb_num].line = 0;
} }
else else
@ -717,15 +702,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
cb.name = name; cb.name = name;
} }
char buf[32]; cb.file = CopyString( "[unknown]" );
const auto addrlen = sprintf( buf, " [%p]", (void*)ptr );
const auto loclen = strlen( symloc );
auto loc = (char*)tracy_malloc( loclen + addrlen + 1 );
memcpy( loc, symloc, loclen );
memcpy( loc + loclen, buf, addrlen );
loc[loclen + addrlen] = '\0';
cb.file = loc;
cb.symLen = 0; cb.symLen = 0;
cb.symAddr = (uint64_t)symaddr; cb.symAddr = (uint64_t)symaddr;