diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index c8163922..76e509ac 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -495,6 +495,15 @@ static const char* GetHostInfo() return buf; } +static uint64_t GetPid() +{ +#if defined _WIN32 || defined __CYGWIN__ + return uint64_t( GetCurrentProcessId() ); +#else + return uint64_t( getpid() ); +#endif +} + static BroadcastMessage& GetBroadcastMessage( const char* procname, size_t pnsz, int& len ) { static BroadcastMessage msg; @@ -1157,6 +1166,8 @@ void Profiler::Worker() const auto hostinfo = GetHostInfo(); const auto hisz = std::min( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 ); + const uint64_t pid = GetPid(); + #ifdef TRACY_ON_DEMAND uint8_t onDemand = 1; #else @@ -1176,6 +1187,7 @@ void Profiler::Worker() MemWrite( &welcome.delay, m_delay ); MemWrite( &welcome.resolution, m_resolution ); MemWrite( &welcome.epoch, m_epoch ); + MemWrite( &welcome.pid, pid ); MemWrite( &welcome.onDemand, onDemand ); MemWrite( &welcome.isApple, isApple ); memcpy( welcome.programName, procname, pnsz ); diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index e0dfacc1..3cb30994 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -9,7 +9,7 @@ namespace tracy { -enum : uint32_t { ProtocolVersion = 16 }; +enum : uint32_t { ProtocolVersion = 17 }; enum : uint32_t { BroadcastVersion = 0 }; using lz4sz_t = uint32_t; @@ -66,6 +66,7 @@ struct WelcomeMessage uint64_t delay; uint64_t resolution; uint64_t epoch; + uint64_t pid; uint8_t onDemand; uint8_t isApple; char programName[WelcomeMessageProgramNameSize]; diff --git a/server/TracyVersion.hpp b/server/TracyVersion.hpp index 25b75cb8..7aeb790e 100644 --- a/server/TracyVersion.hpp +++ b/server/TracyVersion.hpp @@ -7,7 +7,7 @@ namespace Version { enum { Major = 0 }; enum { Minor = 5 }; -enum { Patch = 4 }; +enum { Patch = 5 }; } } diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index a8761478..9c9076a2 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -324,6 +324,15 @@ Worker::Worker( FileRead& f, EventType::Type eventMask ) f.Read( m_data.lastTime ); f.Read( m_data.frameOffset ); + if( fileVer >= FileVersion( 0, 5, 5 ) ) + { + f.Read( m_pid ); + } + else + { + m_pid = 0; + } + uint64_t sz; { f.Read( sz ); @@ -2099,6 +2108,7 @@ void Worker::Exec() m_data.lastTime = initEnd; m_delay = TscTime( welcome.delay ); m_resolution = TscTime( welcome.resolution ); + m_pid = welcome.pid; m_onDemand = welcome.onDemand; m_captureProgram = welcome.programName; m_captureTime = welcome.epoch; @@ -4676,6 +4686,7 @@ void Worker::Write( FileWrite& f ) f.Write( &m_timerMul, sizeof( m_timerMul ) ); f.Write( &m_data.lastTime, sizeof( m_data.lastTime ) ); f.Write( &m_data.frameOffset, sizeof( m_data.frameOffset ) ); + f.Write( &m_pid, sizeof( m_pid ) ); uint64_t sz = m_captureName.size(); f.Write( &sz, sizeof( sz ) ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 67be1353..9bea2cec 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -274,6 +274,7 @@ public: const std::string& GetHostInfo() const { return m_hostInfo; } int64_t GetDelay() const { return m_delay; } int64_t GetResolution() const { return m_resolution; } + uint64_t GetPid() const { return m_pid; }; std::shared_mutex& GetDataLock() { return m_data.lock; } size_t GetFrameCount( const FrameData& fd ) const { return fd.frames.size(); } @@ -544,6 +545,7 @@ private: std::string m_captureProgram; uint64_t m_captureTime; std::string m_hostInfo; + uint64_t m_pid; bool m_terminate = false; bool m_crashed = false; bool m_disconnect = false;