Handle frame name queries.

This commit is contained in:
Bartosz Taudul 2018-08-04 20:48:21 +02:00
parent 4424a7d7e8
commit 9b4348b497
4 changed files with 20 additions and 1 deletions

View File

@ -660,7 +660,7 @@ bool Profiler::SendData( const char* data, size_t len )
void Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
{
assert( type == QueueType::StringData || type == QueueType::ThreadName || type == QueueType::CustomStringData || type == QueueType::PlotName );
assert( type == QueueType::StringData || type == QueueType::ThreadName || type == QueueType::CustomStringData || type == QueueType::PlotName || type == QueueType::FrameName );
QueueItem item;
MemWrite( &item.hdr.type, type );
@ -806,6 +806,9 @@ bool Profiler::HandleServerQuery()
case ServerQueryCallstackFrame:
SendCallstackFrame( ptr );
break;
case ServerQueryFrameName:
SendString( ptr, (const char*)ptr, QueueType::FrameName );
break;
default:
assert( false );
break;

View File

@ -47,6 +47,7 @@ enum class QueueType : uint8_t
PlotName,
SourceLocationPayload,
CallstackPayload,
FrameName,
NUM_TYPES
};
@ -316,6 +317,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // allocated source location payload
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // callstack payload
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // frame name
};
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );

View File

@ -1283,6 +1283,9 @@ void Worker::DispatchProcess( const QueueItem& ev, char*& ptr )
case QueueType::CallstackPayload:
AddCallstackPayload( ev.stringTransfer.ptr, ptr, sz );
break;
case QueueType::FrameName:
HandleFrameName( ev.stringTransfer.ptr, ptr, sz );
break;
default:
assert( false );
break;
@ -1662,6 +1665,16 @@ void Worker::HandlePlotName( uint64_t name, char* str, size_t sz )
} );
}
void Worker::HandleFrameName( uint64_t name, char* str, size_t sz )
{
const auto sl = StoreString( str, sz );
m_data.frames.StringDiscovered( name, sl, m_data.strings, [this] ( FrameData* dst, FrameData* src ) {
auto sz = dst->frames.size();
dst->frames.insert( dst->frames.end(), src->frames.begin(), src->frames.end() );
std::inplace_merge( dst->frames.begin(), dst->frames.begin() + sz, dst->frames.end() );
} );
}
void Worker::HandlePostponedPlots()
{
for( auto& plot : m_data.plots.Data() )

View File

@ -324,6 +324,7 @@ private:
void InsertPlot( PlotData* plot, int64_t time, double val );
void HandlePlotName( uint64_t name, char* str, size_t sz );
void HandleFrameName( uint64_t name, char* str, size_t sz );
void HandlePostponedPlots();