Save executable file names next to build identifiers.

This commit is contained in:
Bartosz Taudul 2022-05-01 12:43:15 +02:00
parent b4343d58f1
commit 20cfdc3022
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,5 @@
#define TRACY_DEBUGINFOD
#include <new> #include <new>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -571,6 +573,7 @@ struct DebugInfo
{ {
uint8_t* buildid; uint8_t* buildid;
size_t buildid_size; size_t buildid_size;
char* filename;
int fd; int fd;
}; };
@ -690,6 +693,7 @@ void ClearDebugInfoVector( FastVector<DebugInfo>& vec )
for( auto& v : vec ) for( auto& v : vec )
{ {
tracy_free( v.buildid ); tracy_free( v.buildid );
tracy_free( v.filename );
if( v.fd >= 0 ) close( v.fd ); if( v.fd >= 0 ) close( v.fd );
} }
vec.clear(); vec.clear();
@ -707,7 +711,7 @@ DebugInfo* FindDebugInfo( FastVector<DebugInfo>& vec, const uint8_t* buildid_dat
return nullptr; return nullptr;
} }
int GetDebugInfoDescriptor( const char* buildid_data, size_t buildid_size ) int GetDebugInfoDescriptor( const char* buildid_data, size_t buildid_size, const char* filename )
{ {
auto buildid = (uint8_t*)buildid_data; auto buildid = (uint8_t*)buildid_data;
auto it = FindDebugInfo( s_di_known, buildid, buildid_size ); auto it = FindDebugInfo( s_di_known, buildid, buildid_size );
@ -718,6 +722,9 @@ int GetDebugInfoDescriptor( const char* buildid_data, size_t buildid_size )
it->buildid_size = buildid_size; it->buildid_size = buildid_size;
it->buildid = (uint8_t*)tracy_malloc( buildid_size ); it->buildid = (uint8_t*)tracy_malloc( buildid_size );
memcpy( it->buildid, buildid, buildid_size ); memcpy( it->buildid, buildid, buildid_size );
const auto fnsz = strlen( filename ) + 1;
it->filename = (char*)tracy_malloc( fnsz );
memcpy( it->filename, filename, fnsz );
it->fd = fd >= 0 ? fd : -1; it->fd = fd >= 0 ? fd : -1;
return it->fd; return it->fd;
} }

View File

@ -923,7 +923,7 @@ elf_open_debugfile_by_buildid (struct backtrace_state *state,
#ifdef TRACY_DEBUGINFOD #ifdef TRACY_DEBUGINFOD
if (ret == -1) if (ret == -1)
return GetDebugInfoDescriptor( buildid_data, buildid_size ); return GetDebugInfoDescriptor( buildid_data, buildid_size, filename );
else else
return ret; return ret;
#else #else