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 "../common/TracySystem.hpp"
|
||||||
#include "concurrentqueue.h"
|
#include "concurrentqueue.h"
|
||||||
#include "TracyProfiler.hpp"
|
#include "TracyProfiler.hpp"
|
||||||
|
#include "TracyThread.hpp"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
# define DISABLE_LZ4
|
# 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 )
|
bool Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
|
||||||
{
|
{
|
||||||
assert( type == QueueType::StringData );
|
assert( type == QueueType::StringData || type == QueueType::ThreadName );
|
||||||
|
|
||||||
QueueHeader hdr;
|
QueueHeader hdr;
|
||||||
hdr.type = type;
|
hdr.type = type;
|
||||||
@ -228,6 +229,9 @@ bool Profiler::HandleServerQuery()
|
|||||||
case ServerQueryString:
|
case ServerQueryString:
|
||||||
SendString( ptr, (const char*)ptr, QueueType::StringData );
|
SendString( ptr, (const char*)ptr, QueueType::StringData );
|
||||||
break;
|
break;
|
||||||
|
case ServerQueryThreadString:
|
||||||
|
SendString( ptr, GetThreadName( ptr ), QueueType::ThreadName );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
|
@ -151,7 +151,7 @@ close:
|
|||||||
|
|
||||||
void View::DispatchProcess( const QueueItem& ev )
|
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;
|
timeval tv;
|
||||||
tv.tv_sec = 0;
|
tv.tv_sec = 0;
|
||||||
@ -161,7 +161,14 @@ void View::DispatchProcess( const QueueItem& ev )
|
|||||||
uint16_t sz;
|
uint16_t sz;
|
||||||
m_sock.Read( &sz, sizeof( sz ), &tv, ShouldExit );
|
m_sock.Read( &sz, sizeof( sz ), &tv, ShouldExit );
|
||||||
m_sock.Read( buf, sz, &tv, ShouldExit );
|
m_sock.Read( buf, sz, &tv, ShouldExit );
|
||||||
AddString( ev.hdr.id, std::string( buf, buf+sz ) );
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -172,12 +179,19 @@ void View::DispatchProcess( const QueueItem& ev )
|
|||||||
void View::DispatchProcess( const QueueItem& ev, const char*& ptr )
|
void View::DispatchProcess( const QueueItem& ev, const char*& ptr )
|
||||||
{
|
{
|
||||||
ptr += QueueDataSize[ev.hdr.idx];
|
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;
|
uint16_t sz;
|
||||||
memcpy( &sz, ptr, sizeof( sz ) );
|
memcpy( &sz, ptr, sizeof( sz ) );
|
||||||
ptr += sizeof( sz );
|
ptr += sizeof( sz );
|
||||||
AddString( ev.hdr.id, std::string( ptr, ptr+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;
|
ptr += sz;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -302,7 +316,10 @@ void View::CheckThreadString( uint64_t id )
|
|||||||
if( m_pendingThreads.find( id ) != m_pendingThreads.end() ) return;
|
if( m_pendingThreads.find( id ) != m_pendingThreads.end() ) return;
|
||||||
|
|
||||||
m_pendingThreads.emplace( id );
|
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 )
|
void View::AddString( uint64_t ptr, std::string&& str )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user