From a47c7d467fec98f520a8d899d482bc5b26cb4741 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 May 2020 18:57:05 +0200 Subject: [PATCH] Send x86 processor info in welcome message. --- client/TracyProfiler.cpp | 17 +++++++++++++++++ common/TracyProtocol.hpp | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index e1466d43..d3614edc 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1217,6 +1217,21 @@ void Profiler::Worker() uint8_t cpuArch = CpuArchUnknown; #endif +#if defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 + uint32_t regs[4]; + char manufacturer[12]; + CpuId( regs, 0 ); + memcpy( manufacturer, regs+1, 4 ); + memcpy( manufacturer+4, regs+3, 4 ); + memcpy( manufacturer+8, regs+2, 4 ); + + CpuId( regs, 1 ); + uint32_t cpuId = ( regs[0] & 0xFFF ) | ( ( regs[0] & 0xFFF0000 ) >> 4 ); +#else + const char manufacturer[12] = {}; + uint32_t cpuId = 0; +#endif + WelcomeMessage welcome; MemWrite( &welcome.timerMul, m_timerMul ); MemWrite( &welcome.initBegin, GetInitTime() ); @@ -1229,6 +1244,8 @@ void Profiler::Worker() MemWrite( &welcome.onDemand, onDemand ); MemWrite( &welcome.isApple, isApple ); MemWrite( &welcome.cpuArch, cpuArch ); + memcpy( welcome.cpuManufacturer, manufacturer, 12 ); + MemWrite( &welcome.cpuId, cpuId ); memcpy( welcome.programName, procname, pnsz ); memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz ); memcpy( welcome.hostInfo, hostinfo, hisz ); diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index 4dd9fa4f..ce52f57e 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -9,7 +9,7 @@ namespace tracy constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; } -enum : uint32_t { ProtocolVersion = 30 }; +enum : uint32_t { ProtocolVersion = 31 }; enum : uint32_t { BroadcastVersion = 1 }; using lz4sz_t = uint32_t; @@ -87,6 +87,8 @@ struct WelcomeMessage uint8_t onDemand; uint8_t isApple; uint8_t cpuArch; + char cpuManufacturer[12]; + uint32_t cpuId; char programName[WelcomeMessageProgramNameSize]; char hostInfo[WelcomeMessageHostInfoSize]; };