tracy/common/TracyProtocol.hpp

124 lines
2.6 KiB
C++
Raw Normal View History

#ifndef __TRACYPROTOCOL_HPP__
#define __TRACYPROTOCOL_HPP__
#include <limits>
#include <stdint.h>
namespace tracy
{
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
enum : uint32_t { ProtocolVersion = 32 };
2020-03-08 13:37:59 +00:00
enum : uint32_t { BroadcastVersion = 1 };
2017-10-19 21:48:16 +00:00
using lz4sz_t = uint32_t;
2017-09-13 20:58:04 +00:00
2017-10-19 21:48:16 +00:00
enum { TargetFrameSize = 256 * 1024 };
enum { LZ4Size = Lz4CompressBound( TargetFrameSize ) };
2017-09-13 20:58:04 +00:00
static_assert( LZ4Size <= std::numeric_limits<lz4sz_t>::max(), "LZ4Size greater than lz4sz_t" );
static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" );
enum { HandshakeShibbolethSize = 8 };
static const char HandshakeShibboleth[HandshakeShibbolethSize] = { 'T', 'r', 'a', 'c', 'y', 'P', 'r', 'f' };
enum HandshakeStatus : uint8_t
{
HandshakePending,
HandshakeWelcome,
HandshakeProtocolMismatch,
HandshakeNotAvailable,
HandshakeDropped
};
2017-10-03 21:17:58 +00:00
enum { WelcomeMessageProgramNameSize = 64 };
2018-08-19 16:19:12 +00:00
enum { WelcomeMessageHostInfoSize = 1024 };
2017-10-03 21:17:58 +00:00
2018-07-10 20:29:31 +00:00
#pragma pack( 1 )
2020-03-25 19:33:50 +00:00
// Must increase left query space after handling!
2019-04-01 16:52:32 +00:00
enum ServerQuery : uint8_t
{
ServerQueryTerminate,
ServerQueryString,
ServerQueryThreadString,
ServerQuerySourceLocation,
ServerQueryPlotName,
ServerQueryCallstackFrame,
ServerQueryFrameName,
ServerQueryDisconnect,
ServerQueryExternalName,
2020-02-26 21:35:15 +00:00
ServerQueryParameter,
ServerQuerySymbol,
ServerQuerySymbolCode,
ServerQueryCodeLocation
2019-04-01 16:52:32 +00:00
};
struct ServerQueryPacket
{
ServerQuery type;
uint64_t ptr;
2020-03-25 19:04:01 +00:00
uint32_t extra;
2019-04-01 16:52:32 +00:00
};
enum { ServerQueryPacketSize = sizeof( ServerQueryPacket ) };
enum CpuArchitecture : uint8_t
{
CpuArchUnknown,
CpuArchX86,
CpuArchX64,
CpuArchArm32,
CpuArchArm64
};
struct WelcomeMessage
{
double timerMul;
int64_t initBegin;
int64_t initEnd;
uint64_t delay;
2017-09-29 16:32:07 +00:00
uint64_t resolution;
uint64_t epoch;
2019-08-17 20:19:04 +00:00
uint64_t pid;
int64_t samplingPeriod;
uint8_t onDemand;
uint8_t isApple;
uint8_t cpuArch;
char cpuManufacturer[12];
uint32_t cpuId;
2017-10-03 21:17:58 +00:00
char programName[WelcomeMessageProgramNameSize];
2018-08-19 16:19:12 +00:00
char hostInfo[WelcomeMessageHostInfoSize];
};
2017-10-03 21:17:58 +00:00
enum { WelcomeMessageSize = sizeof( WelcomeMessage ) };
struct OnDemandPayloadMessage
{
uint64_t frames;
uint64_t currentTime;
};
enum { OnDemandPayloadMessageSize = sizeof( OnDemandPayloadMessage ) };
struct BroadcastMessage
{
uint32_t broadcastVersion;
uint32_t protocolVersion;
2020-03-08 13:37:59 +00:00
uint32_t listenPort;
2019-06-18 18:46:12 +00:00
uint32_t activeTime; // in seconds
char programName[WelcomeMessageProgramNameSize];
};
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
2018-07-10 20:29:31 +00:00
#pragma pack()
}
#endif