mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Thread name queries.
This commit is contained in:
parent
70ad3407c0
commit
6525e1b3c1
@ -14,6 +14,7 @@
|
||||
#include "../common/TracySystem.hpp"
|
||||
#include "concurrentqueue.h"
|
||||
#include "TracyProfiler.hpp"
|
||||
#include "TracyThread.hpp"
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define DISABLE_LZ4
|
||||
@ -189,7 +190,7 @@ bool Profiler::SendData( const char* data, size_t len )
|
||||
|
||||
bool Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
|
||||
{
|
||||
assert( type == QueueType::StringData );
|
||||
assert( type == QueueType::StringData || type == QueueType::ThreadName );
|
||||
|
||||
QueueHeader hdr;
|
||||
hdr.type = type;
|
||||
@ -228,6 +229,9 @@ bool Profiler::HandleServerQuery()
|
||||
case ServerQueryString:
|
||||
SendString( ptr, (const char*)ptr, QueueType::StringData );
|
||||
break;
|
||||
case ServerQueryThreadString:
|
||||
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
|
@ -151,7 +151,7 @@ close:
|
||||
|
||||
void View::DispatchProcess( const QueueItem& ev )
|
||||
{
|
||||
if( ev.hdr.type == QueueType::StringData )
|
||||
if( ev.hdr.type == QueueType::StringData || ev.hdr.type == QueueType::ThreadName )
|
||||
{
|
||||
timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
@ -161,9 +161,16 @@ void View::DispatchProcess( const QueueItem& ev )
|
||||
uint16_t sz;
|
||||
m_sock.Read( &sz, sizeof( sz ), &tv, ShouldExit );
|
||||
m_sock.Read( buf, sz, &tv, ShouldExit );
|
||||
if( ev.hdr.type == QueueType::StringData )
|
||||
{
|
||||
AddString( ev.hdr.id, std::string( buf, buf+sz ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddThreadString( ev.hdr.id, std::string( buf, buf+sz ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Process( ev );
|
||||
}
|
||||
@ -172,12 +179,19 @@ void View::DispatchProcess( const QueueItem& ev )
|
||||
void View::DispatchProcess( const QueueItem& ev, const char*& ptr )
|
||||
{
|
||||
ptr += QueueDataSize[ev.hdr.idx];
|
||||
if( ev.hdr.type == QueueType::StringData )
|
||||
if( ev.hdr.type == QueueType::StringData || ev.hdr.type == QueueType::ThreadName )
|
||||
{
|
||||
uint16_t sz;
|
||||
memcpy( &sz, ptr, sizeof( sz ) );
|
||||
ptr += sizeof( sz );
|
||||
if( ev.hdr.type == QueueType::StringData )
|
||||
{
|
||||
AddString( ev.hdr.id, std::string( ptr, ptr+sz ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddThreadString( ev.hdr.id, std::string( ptr, ptr+sz ) );
|
||||
}
|
||||
ptr += sz;
|
||||
}
|
||||
else
|
||||
@ -302,7 +316,10 @@ void View::CheckThreadString( uint64_t id )
|
||||
if( m_pendingThreads.find( id ) != m_pendingThreads.end() ) return;
|
||||
|
||||
m_pendingThreads.emplace( id );
|
||||
// TODO send
|
||||
|
||||
uint8_t type = ServerQueryThreadString;
|
||||
m_sock.Send( &type, sizeof( type ) );
|
||||
m_sock.Send( &id, sizeof( id ) );
|
||||
}
|
||||
|
||||
void View::AddString( uint64_t ptr, std::string&& str )
|
||||
|
Loading…
x
Reference in New Issue
Block a user