mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Query debuginfod for source code.
This commit is contained in:
parent
726b70b683
commit
6e6f19d8f7
@ -45,6 +45,10 @@
|
||||
# include <vector>
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_DEBUGINFOD
|
||||
# include <elfutils/debuginfod.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <atomic>
|
||||
@ -3838,6 +3842,44 @@ void Profiler::HandleSourceCodeQuery()
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
}
|
||||
#ifdef TRACY_DEBUGINFOD
|
||||
else if( m_queryImage )
|
||||
{
|
||||
size_t size;
|
||||
auto buildid = GetBuildIdForImage( m_queryImage, size );
|
||||
if( buildid )
|
||||
{
|
||||
auto d = debuginfod_find_source( GetDebuginfodClient(), buildid, size, m_queryData, nullptr );
|
||||
if( d >= 0 )
|
||||
{
|
||||
struct stat st;
|
||||
fstat( d, &st );
|
||||
lseek( d, 0, SEEK_SET );
|
||||
auto ptr = (char*)tracy_malloc_fast( st.st_size );
|
||||
auto rd = read( d, ptr, st.st_size );
|
||||
close( d );
|
||||
if( rd == (size_t)st.st_size )
|
||||
{
|
||||
SendLongString( (uint64_t)ptr, ptr, rd, QueueType::SourceCode );
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
tracy_free_fast( ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
tracy_free_fast( m_queryData );
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
tracy_free_fast( m_queryData );
|
||||
|
Loading…
x
Reference in New Issue
Block a user