1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-07 23:43:52 +00:00

Callstack frame transfer.

This commit is contained in:
Bartosz Taudul 2018-06-20 01:06:31 +02:00
parent 359feae7ef
commit 5177a7b960
3 changed files with 36 additions and 0 deletions

View File

@ -559,6 +559,27 @@ void Profiler::SendCallstackPayload( uint64_t _ptr )
}
}
void Profiler::SendCallstackFrame( uint64_t ptr )
{
#ifdef TRACY_HAS_CALLSTACK
auto frame = DecodeCallstackPtr( ptr );
SendString( uint64_t( frame.name ), frame.name, QueueType::CustomStringData );
QueueItem item;
MemWrite( &item.hdr.type, QueueType::CallstackFrame );
MemWrite( &item.callstackFrame.ptr, ptr );
MemWrite( &item.callstackFrame.name, (uint64_t)frame.name );
MemWrite( &item.callstackFrame.file, (uint64_t)frame.file );
MemWrite( &item.callstackFrame.line, frame.line );
NeedDataSize( QueueDataSize[(int)QueueType::CallstackFrame] );
AppendData( &item, QueueDataSize[(int)QueueType::CallstackFrame] );
tracy_free( (void*)frame.name );
#endif
}
static bool DontExit() { return false; }
@ -597,6 +618,9 @@ bool Profiler::HandleServerQuery()
break;
case ServerQueryTerminate:
return false;
case ServerQueryCallstackFrame:
SendCallstackFrame( ptr );
break;
default:
assert( false );
break;

View File

@ -301,6 +301,7 @@ private:
void SendSourceLocation( uint64_t ptr );
void SendSourceLocationPayload( uint64_t ptr );
void SendCallstackPayload( uint64_t ptr );
void SendCallstackFrame( uint64_t ptr );
bool HandleServerQuery();

View File

@ -36,6 +36,7 @@ enum class QueueType : uint8_t
MemFree,
MemAllocCallstack,
MemFreeCallstack,
CallstackFrame,
StringData,
ThreadName,
CustomStringData,
@ -215,6 +216,14 @@ struct QueueCallstackMemory
uint64_t ptr;
};
struct QueueCallstackFrame
{
uint64_t ptr;
uint64_t name;
uint64_t file;
uint32_t line;
};
struct QueueHeader
{
union
@ -250,6 +259,7 @@ struct QueueItem
QueueMemAlloc memAlloc;
QueueMemFree memFree;
QueueCallstackMemory callstackMemory;
QueueCallstackFrame callstackFrame;
};
};
@ -287,6 +297,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueMemFree ),
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), // callstack
sizeof( QueueHeader ) + sizeof( QueueMemFree ), // callstack
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
// keep all QueueStringTransfer below
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name