mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Make source code query handling easier to follow.
Also, limit debuginfod source file upload to not exceed target frame size.
This commit is contained in:
parent
b6f155bb6a
commit
6455fcfa91
@ -3813,11 +3813,13 @@ void Profiler::HandleSourceCodeQuery()
|
||||
assert( m_queryData );
|
||||
|
||||
InitRpmalloc();
|
||||
bool ok = false;
|
||||
struct stat st;
|
||||
if( stat( m_queryData, &st ) == 0 && (uint64_t)st.st_mtime < m_exectime && st.st_size < ( TargetFrameSize - 16 ) )
|
||||
if( stat( m_queryData, &st ) == 0 && (uint64_t)st.st_mtime < m_exectime )
|
||||
{
|
||||
if( st.st_size < ( TargetFrameSize - 16 ) )
|
||||
{
|
||||
FILE* f = fopen( m_queryData, "rb" );
|
||||
tracy_free_fast( m_queryData );
|
||||
if( f )
|
||||
{
|
||||
auto ptr = (char*)tracy_malloc_fast( st.st_size );
|
||||
@ -3826,16 +3828,10 @@ void Profiler::HandleSourceCodeQuery()
|
||||
if( rd == (size_t)st.st_size )
|
||||
{
|
||||
SendLongString( (uint64_t)ptr, ptr, rd, QueueType::SourceCode );
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
ok = true;
|
||||
}
|
||||
tracy_free_fast( ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
}
|
||||
#ifdef TRACY_DEBUGINFOD
|
||||
@ -3850,44 +3846,30 @@ void Profiler::HandleSourceCodeQuery()
|
||||
{
|
||||
struct stat st;
|
||||
fstat( d, &st );
|
||||
if( st.st_size < ( TargetFrameSize - 16 ) )
|
||||
{
|
||||
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();
|
||||
ok = true;
|
||||
}
|
||||
tracy_free_fast( ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
close( d );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
tracy_free_fast( m_queryData );
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
tracy_free_fast( m_queryData );
|
||||
AckSourceCodeNotAvailable();
|
||||
}
|
||||
m_queryData = nullptr;
|
||||
|
||||
if( m_queryImage )
|
||||
{
|
||||
if( !ok ) AckSourceCodeNotAvailable();
|
||||
|
||||
tracy_free_fast( m_queryData );
|
||||
tracy_free_fast( m_queryImage );
|
||||
m_queryData = nullptr;
|
||||
m_queryImage = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined _WIN32 && defined TRACY_TIMER_QPC
|
||||
|
Loading…
Reference in New Issue
Block a user