mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Data packets can't cross data buffer boundary.
This commit is contained in:
parent
49bce256bc
commit
c2797a4cc7
@ -276,7 +276,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
bool Profiler::AppendData( const void* data, size_t len )
|
bool Profiler::AppendData( const void* data, size_t len )
|
||||||
{
|
{
|
||||||
auto ret = true;
|
auto ret = true;
|
||||||
if( m_bufferOffset - m_bufferStart + len > TargetFrameSize ) ret = CommitData();
|
ret = NeedDataSize( len );
|
||||||
memcpy( m_buffer + m_bufferOffset, data, len );
|
memcpy( m_buffer + m_bufferOffset, data, len );
|
||||||
m_bufferOffset += int( len );
|
m_bufferOffset += int( len );
|
||||||
return ret;
|
return ret;
|
||||||
@ -290,6 +290,16 @@ bool Profiler::CommitData()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Profiler::NeedDataSize( size_t len )
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
if( m_bufferOffset - m_bufferStart + len > TargetFrameSize )
|
||||||
|
{
|
||||||
|
ret = CommitData();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool Profiler::SendData( const char* data, size_t len )
|
bool Profiler::SendData( const char* data, size_t len )
|
||||||
{
|
{
|
||||||
const lz4sz_t lz4sz = LZ4_compress_fast_continue( m_stream, data, m_lz4Buf + sizeof( lz4sz_t ), (int)len, LZ4Size, 1 );
|
const lz4sz_t lz4sz = LZ4_compress_fast_continue( m_stream, data, m_lz4Buf + sizeof( lz4sz_t ), (int)len, LZ4Size, 1 );
|
||||||
@ -304,11 +314,14 @@ bool Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
|
|||||||
QueueItem item;
|
QueueItem item;
|
||||||
item.hdr.type = type;
|
item.hdr.type = type;
|
||||||
item.stringTransfer.ptr = str;
|
item.stringTransfer.ptr = str;
|
||||||
AppendData( &item, QueueDataSize[item.hdr.idx] );
|
|
||||||
|
|
||||||
auto len = strlen( ptr );
|
auto len = strlen( ptr );
|
||||||
assert( len <= std::numeric_limits<uint16_t>::max() );
|
assert( len <= std::numeric_limits<uint16_t>::max() );
|
||||||
auto l16 = uint16_t( len );
|
auto l16 = uint16_t( len );
|
||||||
|
|
||||||
|
NeedDataSize( QueueDataSize[item.hdr.idx] + sizeof( l16 ) + l16 );
|
||||||
|
|
||||||
|
AppendData( &item, QueueDataSize[item.hdr.idx] );
|
||||||
AppendData( &l16, sizeof( l16 ) );
|
AppendData( &l16, sizeof( l16 ) );
|
||||||
AppendData( ptr, l16 );
|
AppendData( ptr, l16 );
|
||||||
|
|
||||||
@ -337,12 +350,15 @@ bool Profiler::SendSourceLocationPayload( uint64_t _ptr )
|
|||||||
QueueItem item;
|
QueueItem item;
|
||||||
item.hdr.type = QueueType::SourceLocationPayload;
|
item.hdr.type = QueueType::SourceLocationPayload;
|
||||||
item.stringTransfer.ptr = _ptr;
|
item.stringTransfer.ptr = _ptr;
|
||||||
AppendData( &item, QueueDataSize[item.hdr.idx] );
|
|
||||||
|
|
||||||
const auto len = *((uint32_t*)ptr);
|
const auto len = *((uint32_t*)ptr);
|
||||||
assert( len <= std::numeric_limits<uint16_t>::max() );
|
assert( len <= std::numeric_limits<uint16_t>::max() );
|
||||||
assert( len > 4 );
|
assert( len > 4 );
|
||||||
const auto l16 = uint16_t( len - 4 );
|
const auto l16 = uint16_t( len - 4 );
|
||||||
|
|
||||||
|
NeedDataSize( QueueDataSize[item.hdr.idx] + sizeof( l16 ) + l16 );
|
||||||
|
|
||||||
|
AppendData( &item, QueueDataSize[item.hdr.idx] );
|
||||||
AppendData( &l16, sizeof( l16 ) );
|
AppendData( &l16, sizeof( l16 ) );
|
||||||
AppendData( ptr + 4, l16 );
|
AppendData( ptr + 4, l16 );
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ private:
|
|||||||
DequeueStatus Dequeue( moodycamel::ConsumerToken& token );
|
DequeueStatus Dequeue( moodycamel::ConsumerToken& token );
|
||||||
bool AppendData( const void* data, size_t len );
|
bool AppendData( const void* data, size_t len );
|
||||||
bool CommitData();
|
bool CommitData();
|
||||||
|
bool NeedDataSize( size_t len );
|
||||||
|
|
||||||
bool SendData( const char* data, size_t len );
|
bool SendData( const char* data, size_t len );
|
||||||
bool SendString( uint64_t ptr, const char* str, QueueType type );
|
bool SendString( uint64_t ptr, const char* str, QueueType type );
|
||||||
|
Loading…
Reference in New Issue
Block a user