mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Plumbing for message call stacks.
This commit is contained in:
parent
0befc75f83
commit
8286b0b72f
@ -103,10 +103,10 @@
|
|||||||
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
|
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
|
||||||
#define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type );
|
#define TracyPlotConfig( name, type ) tracy::Profiler::ConfigurePlot( name, type );
|
||||||
|
|
||||||
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
|
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size, 0 );
|
||||||
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
|
#define TracyMessageL( txt ) tracy::Profiler::Message( txt, 0 );
|
||||||
#define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color );
|
#define TracyMessageC( txt, size, color ) tracy::Profiler::MessageColor( txt, size, color, 0 );
|
||||||
#define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color );
|
#define TracyMessageLC( txt, color ) tracy::Profiler::MessageColor( txt, color, 0 );
|
||||||
#define TracyAppInfo( txt, size ) tracy::Profiler::MessageAppInfo( txt, size );
|
#define TracyAppInfo( txt, size ) tracy::Profiler::MessageAppInfo( txt, size );
|
||||||
|
|
||||||
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
||||||
|
16
TracyC.h
16
TracyC.h
@ -117,17 +117,17 @@ TRACY_API void ___tracy_emit_frame_image( const void* image, uint16_t w, uint16_
|
|||||||
|
|
||||||
|
|
||||||
TRACY_API void ___tracy_emit_plot( const char* name, double val );
|
TRACY_API void ___tracy_emit_plot( const char* name, double val );
|
||||||
TRACY_API void ___tracy_emit_message( const char* txt, size_t size );
|
TRACY_API void ___tracy_emit_message( const char* txt, size_t size, int callstack );
|
||||||
TRACY_API void ___tracy_emit_messageL( const char* txt );
|
TRACY_API void ___tracy_emit_messageL( const char* txt, int callstack );
|
||||||
TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color );
|
TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color, int callstack );
|
||||||
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color );
|
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int callstack );
|
||||||
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size );
|
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size );
|
||||||
|
|
||||||
#define TracyCPlot( name, val ) ___tracy_emit_plot( name, val );
|
#define TracyCPlot( name, val ) ___tracy_emit_plot( name, val );
|
||||||
#define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size );
|
#define TracyCMessage( txt, size ) ___tracy_emit_message( txt, size, 0 );
|
||||||
#define TracyCMessageL( txt ) ___tracy_emit_messageL( txt );
|
#define TracyCMessageL( txt ) ___tracy_emit_messageL( txt, 0 );
|
||||||
#define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color );
|
#define TracyCMessageC( txt, size, color ) ___tracy_emit_messageC( txt, size, color, 0 );
|
||||||
#define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color );
|
#define TracyCMessageLC( txt, color ) ___tracy_emit_messageLC( txt, color, 0 );
|
||||||
#define TracyCAppInfo( txt, color ) ___tracy_emit_message_appinfo( txt, color );
|
#define TracyCAppInfo( txt, color ) ___tracy_emit_message_appinfo( txt, color );
|
||||||
|
|
||||||
|
|
||||||
|
@ -1599,6 +1599,8 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
|||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
case QueueType::MessageColor:
|
case QueueType::MessageColor:
|
||||||
|
case QueueType::MessageCallstack:
|
||||||
|
case QueueType::MessageColorCallstack:
|
||||||
#ifndef TRACY_ON_DEMAND
|
#ifndef TRACY_ON_DEMAND
|
||||||
case QueueType::MessageAppInfo:
|
case QueueType::MessageAppInfo:
|
||||||
#endif
|
#endif
|
||||||
@ -1706,6 +1708,8 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
case QueueType::MessageColor:
|
case QueueType::MessageColor:
|
||||||
|
case QueueType::MessageCallstack:
|
||||||
|
case QueueType::MessageColorCallstack:
|
||||||
ptr = MemRead<uint64_t>( &item->message.text );
|
ptr = MemRead<uint64_t>( &item->message.text );
|
||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
@ -2665,10 +2669,10 @@ TRACY_API void ___tracy_emit_frame_mark_start( const char* name ) { tracy::Profi
|
|||||||
TRACY_API void ___tracy_emit_frame_mark_end( const char* name ) { tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgEnd ); }
|
TRACY_API void ___tracy_emit_frame_mark_end( const char* name ) { tracy::Profiler::SendFrameMark( name, tracy::QueueType::FrameMarkMsgEnd ); }
|
||||||
TRACY_API void ___tracy_emit_frame_image( const void* image, uint16_t w, uint16_t h, uint8_t offset, int flip ) { tracy::Profiler::SendFrameImage( image, w, h, offset, flip ); }
|
TRACY_API void ___tracy_emit_frame_image( const void* image, uint16_t w, uint16_t h, uint8_t offset, int flip ) { tracy::Profiler::SendFrameImage( image, w, h, offset, flip ); }
|
||||||
TRACY_API void ___tracy_emit_plot( const char* name, double val ) { tracy::Profiler::PlotData( name, val ); }
|
TRACY_API void ___tracy_emit_plot( const char* name, double val ) { tracy::Profiler::PlotData( name, val ); }
|
||||||
TRACY_API void ___tracy_emit_message( const char* txt, size_t size ) { tracy::Profiler::Message( txt, size ); }
|
TRACY_API void ___tracy_emit_message( const char* txt, size_t size, int callstack ) { tracy::Profiler::Message( txt, size, callstack ); }
|
||||||
TRACY_API void ___tracy_emit_messageL( const char* txt ) { tracy::Profiler::Message( txt ); }
|
TRACY_API void ___tracy_emit_messageL( const char* txt, int callstack ) { tracy::Profiler::Message( txt, callstack ); }
|
||||||
TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color ) { tracy::Profiler::MessageColor( txt, size, color ); }
|
TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t color, int callstack ) { tracy::Profiler::MessageColor( txt, size, color, callstack ); }
|
||||||
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color ) { tracy::Profiler::MessageColor( txt, color ); }
|
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int callstack ) { tracy::Profiler::MessageColor( txt, color, callstack ); }
|
||||||
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ) { tracy::Profiler::MessageAppInfo( txt, size ); }
|
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ) { tracy::Profiler::MessageAppInfo( txt, size ); }
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -262,7 +262,7 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void Message( const char* txt, size_t size )
|
static tracy_force_inline void Message( const char* txt, size_t size, int callstack )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -274,13 +274,15 @@ public:
|
|||||||
ptr[size] = '\0';
|
ptr[size] = '\0';
|
||||||
auto& tail = token->get_tail_index();
|
auto& tail = token->get_tail_index();
|
||||||
auto item = token->enqueue_begin( magic );
|
auto item = token->enqueue_begin( magic );
|
||||||
MemWrite( &item->hdr.type, QueueType::Message );
|
MemWrite( &item->hdr.type, callstack == 0 ? QueueType::Message : QueueType::MessageCallstack );
|
||||||
MemWrite( &item->message.time, GetTime() );
|
MemWrite( &item->message.time, GetTime() );
|
||||||
MemWrite( &item->message.text, (uint64_t)ptr );
|
MemWrite( &item->message.text, (uint64_t)ptr );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
|
||||||
|
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void Message( const char* txt )
|
static tracy_force_inline void Message( const char* txt, int callstack )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -289,13 +291,15 @@ public:
|
|||||||
auto token = GetToken();
|
auto token = GetToken();
|
||||||
auto& tail = token->get_tail_index();
|
auto& tail = token->get_tail_index();
|
||||||
auto item = token->enqueue_begin( magic );
|
auto item = token->enqueue_begin( magic );
|
||||||
MemWrite( &item->hdr.type, QueueType::MessageLiteral );
|
MemWrite( &item->hdr.type, callstack == 0 ? QueueType::MessageLiteral : QueueType::MessageLiteralCallstack );
|
||||||
MemWrite( &item->message.time, GetTime() );
|
MemWrite( &item->message.time, GetTime() );
|
||||||
MemWrite( &item->message.text, (uint64_t)txt );
|
MemWrite( &item->message.text, (uint64_t)txt );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
|
||||||
|
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color )
|
static tracy_force_inline void MessageColor( const char* txt, size_t size, uint32_t color, int callstack )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -307,16 +311,18 @@ public:
|
|||||||
ptr[size] = '\0';
|
ptr[size] = '\0';
|
||||||
auto& tail = token->get_tail_index();
|
auto& tail = token->get_tail_index();
|
||||||
auto item = token->enqueue_begin( magic );
|
auto item = token->enqueue_begin( magic );
|
||||||
MemWrite( &item->hdr.type, QueueType::MessageColor );
|
MemWrite( &item->hdr.type, callstack == 0 ? QueueType::MessageColor : QueueType::MessageColorCallstack );
|
||||||
MemWrite( &item->messageColor.time, GetTime() );
|
MemWrite( &item->messageColor.time, GetTime() );
|
||||||
MemWrite( &item->messageColor.text, (uint64_t)ptr );
|
MemWrite( &item->messageColor.text, (uint64_t)ptr );
|
||||||
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||||
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||||
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
|
||||||
|
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void MessageColor( const char* txt, uint32_t color )
|
static tracy_force_inline void MessageColor( const char* txt, uint32_t color, int callstack )
|
||||||
{
|
{
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !GetProfiler().IsConnected() ) return;
|
||||||
@ -325,13 +331,15 @@ public:
|
|||||||
auto token = GetToken();
|
auto token = GetToken();
|
||||||
auto& tail = token->get_tail_index();
|
auto& tail = token->get_tail_index();
|
||||||
auto item = token->enqueue_begin( magic );
|
auto item = token->enqueue_begin( magic );
|
||||||
MemWrite( &item->hdr.type, QueueType::MessageLiteralColor );
|
MemWrite( &item->hdr.type, callstack == 0 ? QueueType::MessageLiteralColor : QueueType::MessageLiteralColorCallstack );
|
||||||
MemWrite( &item->messageColor.time, GetTime() );
|
MemWrite( &item->messageColor.time, GetTime() );
|
||||||
MemWrite( &item->messageColor.text, (uint64_t)txt );
|
MemWrite( &item->messageColor.text, (uint64_t)txt );
|
||||||
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
MemWrite( &item->messageColor.r, uint8_t( ( color ) & 0xFF ) );
|
||||||
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
MemWrite( &item->messageColor.g, uint8_t( ( color >> 8 ) & 0xFF ) );
|
||||||
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
MemWrite( &item->messageColor.b, uint8_t( ( color >> 16 ) & 0xFF ) );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
|
||||||
|
if( callstack != 0 ) tracy::GetProfiler().SendCallstack( callstack );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
static tracy_force_inline void MessageAppInfo( const char* txt, size_t size )
|
||||||
|
@ -9,7 +9,7 @@ namespace tracy
|
|||||||
|
|
||||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 22 };
|
enum : uint32_t { ProtocolVersion = 23 };
|
||||||
enum : uint32_t { BroadcastVersion = 0 };
|
enum : uint32_t { BroadcastVersion = 0 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
@ -12,6 +12,8 @@ enum class QueueType : uint8_t
|
|||||||
ZoneName,
|
ZoneName,
|
||||||
Message,
|
Message,
|
||||||
MessageColor,
|
MessageColor,
|
||||||
|
MessageCallstack,
|
||||||
|
MessageColorCallstack,
|
||||||
MessageAppInfo,
|
MessageAppInfo,
|
||||||
ZoneBeginAllocSrcLoc,
|
ZoneBeginAllocSrcLoc,
|
||||||
ZoneBeginAllocSrcLocCallstack,
|
ZoneBeginAllocSrcLocCallstack,
|
||||||
@ -57,6 +59,8 @@ enum class QueueType : uint8_t
|
|||||||
LockMark,
|
LockMark,
|
||||||
MessageLiteral,
|
MessageLiteral,
|
||||||
MessageLiteralColor,
|
MessageLiteralColor,
|
||||||
|
MessageLiteralCallstack,
|
||||||
|
MessageLiteralColorCallstack,
|
||||||
GpuNewContext,
|
GpuNewContext,
|
||||||
CallstackFrameSize,
|
CallstackFrameSize,
|
||||||
CallstackFrame,
|
CallstackFrame,
|
||||||
@ -405,6 +409,8 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // callstack
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // callstack
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // app info
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // app info
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack
|
||||||
@ -451,6 +457,8 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
sizeof( QueueHeader ) + sizeof( QueueLockMark ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal, callstack
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal, callstack
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
|
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
|
||||||
|
Loading…
Reference in New Issue
Block a user