diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 3282c2aa..20844e00 100755 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -145,4 +145,25 @@ bool Profiler::SendData( const char* data, size_t len ) return true; } +bool Profiler::SendString( uint64_t str ) +{ + auto ptr = (const char*)str; + + QueueHeader hdr; + hdr.type = QueueType::StringData; + hdr.id = str; + + char buf[TargetFrameSize]; + memcpy( buf, &hdr, sizeof( hdr ) ); + + auto len = strlen( ptr ); + assert( len < TargetFrameSize - sizeof( hdr ) - sizeof( uint16_t ) ); + assert( len <= std::numeric_limits::max() ); + uint16_t l16 = len; + memcpy( buf + sizeof( hdr ), &l16, sizeof( l16 ) ); + memcpy( buf + sizeof( hdr ) + sizeof( l16 ), ptr, l16 ); + + return SendData( buf, sizeof( hdr ) + sizeof( l16 ) + l16 ); +} + } diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 6eb0fb01..9a238af4 100755 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -36,6 +36,7 @@ private: void Worker(); bool SendData( const char* data, size_t len ); + bool SendString( uint64_t ptr ); static Profiler* Instance(); static moodycamel::ProducerToken& GetToken() diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 058c4c55..0eb5e73c 100755 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -10,6 +10,7 @@ enum class QueueType : uint8_t { ZoneBegin, ZoneEnd, + StringData, NUM_TYPES }; @@ -55,6 +56,7 @@ enum { QueueItemSize = sizeof( QueueItem ) }; static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), sizeof( QueueHeader ) + sizeof( QueueZoneEnd ), + sizeof( QueueHeader ), }; static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );