mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Collect and issue debuginfod requests.
Build identifiers stored in vectors are searched linearly. While not optimal, this is enough for a basic implementation. In the future binary search option may be explored, to see if it is worthwhile. Possible gains wouldn't be significant, due to relatively small amount of debug info modules to handle. Debug info descriptor requests that have not yet been checked for (i.e. not in the s_di_known vector) are stored in the s_di_pending vector. When a check is performed from within a libbacktrace callback handler, there are some unknown problems with downloading data. Hence, the download process is delayed to be performed at a later time. The debug info descriptors retrieval can be then repeated.
This commit is contained in:
parent
d9fb5c71eb
commit
4549671caa
@ -695,6 +695,48 @@ void ClearDebugInfoVector( FastVector<DebugInfo>& vec )
|
||||
}
|
||||
vec.clear();
|
||||
}
|
||||
|
||||
DebugInfo* FindDebugInfo( FastVector<DebugInfo>& vec, const uint8_t* buildid_data, size_t buildid_size )
|
||||
{
|
||||
for( auto& v : vec )
|
||||
{
|
||||
if( v.buildid_size == buildid_size && memcmp( v.buildid, buildid_data, buildid_size ) == 0 )
|
||||
{
|
||||
return &v;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int GetDebugInfoDescriptor( const char* buildid_data, size_t buildid_size )
|
||||
{
|
||||
auto buildid = (uint8_t*)buildid_data;
|
||||
auto it = FindDebugInfo( s_di_known, buildid, buildid_size );
|
||||
if( it ) return it->fd >= 0 ? dup( it->fd ) : -1;
|
||||
it = FindDebugInfo( s_di_pending, buildid, buildid_size );
|
||||
if( !it )
|
||||
{
|
||||
it = s_di_pending.push_next();
|
||||
it->buildid_size = buildid_size;
|
||||
it->buildid = (uint8_t*)tracy_malloc( buildid_size );
|
||||
memcpy( it->buildid, buildid, buildid_size );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DownloadDebugInfo()
|
||||
{
|
||||
assert( !s_di_pending.empty() );
|
||||
for( auto& v : s_di_pending )
|
||||
{
|
||||
int fd = debuginfod_find_debuginfo( s_debuginfod, (const unsigned char*)v.buildid, v.buildid_size, nullptr );
|
||||
auto it = s_di_known.push_next();
|
||||
it->buildid = v.buildid;
|
||||
it->buildid_size = v.buildid_size;
|
||||
it->fd = fd >= 0 ? fd : -1;
|
||||
}
|
||||
s_di_pending.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
void EndCallstack()
|
||||
|
Loading…
Reference in New Issue
Block a user