2017-09-13 20:56:55 +00:00
|
|
|
#ifndef __TRACYPROTOCOL_HPP__
|
|
|
|
#define __TRACYPROTOCOL_HPP__
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2019-11-06 00:30:20 +00:00
|
|
|
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
|
|
|
|
2022-04-18 11:39:49 +00:00
|
|
|
enum : uint32_t { ProtocolVersion = 56 };
|
2020-09-20 20:23:46 +00:00
|
|
|
enum : uint16_t { BroadcastVersion = 2 };
|
2018-09-09 17:28:53 +00:00
|
|
|
|
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 };
|
2019-11-06 00:30:20 +00:00
|
|
|
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" );
|
2017-09-17 11:24:50 +00:00
|
|
|
static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" );
|
2017-09-13 20:56:55 +00:00
|
|
|
|
2018-09-09 16:26:53 +00:00
|
|
|
enum { HandshakeShibbolethSize = 8 };
|
|
|
|
static const char HandshakeShibboleth[HandshakeShibbolethSize] = { 'T', 'r', 'a', 'c', 'y', 'P', 'r', 'f' };
|
|
|
|
|
2018-09-09 17:28:53 +00:00
|
|
|
enum HandshakeStatus : uint8_t
|
|
|
|
{
|
|
|
|
HandshakePending,
|
|
|
|
HandshakeWelcome,
|
|
|
|
HandshakeProtocolMismatch,
|
2019-02-12 00:41:09 +00:00
|
|
|
HandshakeNotAvailable,
|
|
|
|
HandshakeDropped
|
2018-09-09 17:28:53 +00:00
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
ServerQueryFrameName,
|
2022-04-18 11:39:49 +00:00
|
|
|
ServerQueryParameter,
|
|
|
|
ServerQueryFiberName,
|
|
|
|
// Items above are high priority. Split order must be preserved. See IsQueryPrio().
|
2019-08-16 17:22:23 +00:00
|
|
|
ServerQueryDisconnect,
|
2022-04-18 11:39:49 +00:00
|
|
|
ServerQueryCallstackFrame,
|
2019-11-25 22:59:48 +00:00
|
|
|
ServerQueryExternalName,
|
2020-03-25 19:04:55 +00:00
|
|
|
ServerQuerySymbol,
|
2020-04-01 19:43:03 +00:00
|
|
|
ServerQuerySymbolCode,
|
2021-02-03 23:03:25 +00:00
|
|
|
ServerQueryCodeLocation,
|
|
|
|
ServerQuerySourceCode,
|
|
|
|
ServerQueryDataTransfer,
|
2022-04-18 11:39:49 +00:00
|
|
|
ServerQueryDataTransferPart
|
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 ) };
|
|
|
|
|
|
|
|
|
2020-03-25 20:28:02 +00:00
|
|
|
enum CpuArchitecture : uint8_t
|
|
|
|
{
|
|
|
|
CpuArchUnknown,
|
|
|
|
CpuArchX86,
|
|
|
|
CpuArchX64,
|
|
|
|
CpuArchArm32,
|
|
|
|
CpuArchArm64
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-14 23:26:50 +00:00
|
|
|
struct WelcomeFlag
|
|
|
|
{
|
|
|
|
enum _t : uint8_t
|
|
|
|
{
|
|
|
|
OnDemand = 1 << 0,
|
|
|
|
IsApple = 1 << 1,
|
|
|
|
CodeTransfer = 1 << 2,
|
2021-06-14 23:32:18 +00:00
|
|
|
CombineSamples = 1 << 3,
|
2021-12-04 13:50:25 +00:00
|
|
|
IdentifySamples = 1 << 4,
|
2021-06-14 23:26:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-09-24 14:10:28 +00:00
|
|
|
struct WelcomeMessage
|
|
|
|
{
|
2017-09-25 22:13:24 +00:00
|
|
|
double timerMul;
|
2018-03-31 12:03:55 +00:00
|
|
|
int64_t initBegin;
|
|
|
|
int64_t initEnd;
|
2017-09-24 14:10:28 +00:00
|
|
|
uint64_t delay;
|
2017-09-29 16:32:07 +00:00
|
|
|
uint64_t resolution;
|
2017-10-03 21:26:41 +00:00
|
|
|
uint64_t epoch;
|
2021-01-31 16:45:11 +00:00
|
|
|
uint64_t exectime;
|
2019-08-17 20:19:04 +00:00
|
|
|
uint64_t pid;
|
2020-02-25 22:12:31 +00:00
|
|
|
int64_t samplingPeriod;
|
2021-06-14 23:26:50 +00:00
|
|
|
uint8_t flags;
|
2020-03-25 20:28:02 +00:00
|
|
|
uint8_t cpuArch;
|
2020-05-06 16:57:05 +00:00
|
|
|
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-09-24 14:10:28 +00:00
|
|
|
};
|
|
|
|
|
2017-10-03 21:17:58 +00:00
|
|
|
enum { WelcomeMessageSize = sizeof( WelcomeMessage ) };
|
|
|
|
|
2018-07-10 20:37:39 +00:00
|
|
|
|
|
|
|
struct OnDemandPayloadMessage
|
|
|
|
{
|
|
|
|
uint64_t frames;
|
2019-06-21 17:34:34 +00:00
|
|
|
uint64_t currentTime;
|
2018-07-10 20:37:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum { OnDemandPayloadMessageSize = sizeof( OnDemandPayloadMessage ) };
|
|
|
|
|
2019-06-18 18:26:40 +00:00
|
|
|
|
|
|
|
struct BroadcastMessage
|
|
|
|
{
|
2020-09-20 20:23:46 +00:00
|
|
|
uint16_t broadcastVersion;
|
|
|
|
uint16_t listenPort;
|
2019-06-18 18:26:40 +00:00
|
|
|
uint32_t protocolVersion;
|
2020-09-20 20:15:10 +00:00
|
|
|
int32_t activeTime; // in seconds
|
2019-06-18 18:26:40 +00:00
|
|
|
char programName[WelcomeMessageProgramNameSize];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { BroadcastMessageSize = sizeof( BroadcastMessage ) };
|
|
|
|
|
2018-07-10 20:29:31 +00:00
|
|
|
#pragma pack()
|
|
|
|
|
2017-09-13 20:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|