mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 12:53:51 +00:00
Transfer PID of profiled program.
This commit is contained in:
parent
1024992493
commit
678e942e9f
@ -495,6 +495,15 @@ static const char* GetHostInfo()
|
|||||||
return buf;
|
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& GetBroadcastMessage( const char* procname, size_t pnsz, int& len )
|
||||||
{
|
{
|
||||||
static BroadcastMessage msg;
|
static BroadcastMessage msg;
|
||||||
@ -1157,6 +1166,8 @@ void Profiler::Worker()
|
|||||||
const auto hostinfo = GetHostInfo();
|
const auto hostinfo = GetHostInfo();
|
||||||
const auto hisz = std::min<size_t>( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 );
|
const auto hisz = std::min<size_t>( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 );
|
||||||
|
|
||||||
|
const uint64_t pid = GetPid();
|
||||||
|
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
uint8_t onDemand = 1;
|
uint8_t onDemand = 1;
|
||||||
#else
|
#else
|
||||||
@ -1176,6 +1187,7 @@ void Profiler::Worker()
|
|||||||
MemWrite( &welcome.delay, m_delay );
|
MemWrite( &welcome.delay, m_delay );
|
||||||
MemWrite( &welcome.resolution, m_resolution );
|
MemWrite( &welcome.resolution, m_resolution );
|
||||||
MemWrite( &welcome.epoch, m_epoch );
|
MemWrite( &welcome.epoch, m_epoch );
|
||||||
|
MemWrite( &welcome.pid, pid );
|
||||||
MemWrite( &welcome.onDemand, onDemand );
|
MemWrite( &welcome.onDemand, onDemand );
|
||||||
MemWrite( &welcome.isApple, isApple );
|
MemWrite( &welcome.isApple, isApple );
|
||||||
memcpy( welcome.programName, procname, pnsz );
|
memcpy( welcome.programName, procname, pnsz );
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 16 };
|
enum : uint32_t { ProtocolVersion = 17 };
|
||||||
enum : uint32_t { BroadcastVersion = 0 };
|
enum : uint32_t { BroadcastVersion = 0 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
@ -66,6 +66,7 @@ struct WelcomeMessage
|
|||||||
uint64_t delay;
|
uint64_t delay;
|
||||||
uint64_t resolution;
|
uint64_t resolution;
|
||||||
uint64_t epoch;
|
uint64_t epoch;
|
||||||
|
uint64_t pid;
|
||||||
uint8_t onDemand;
|
uint8_t onDemand;
|
||||||
uint8_t isApple;
|
uint8_t isApple;
|
||||||
char programName[WelcomeMessageProgramNameSize];
|
char programName[WelcomeMessageProgramNameSize];
|
||||||
|
@ -7,7 +7,7 @@ namespace Version
|
|||||||
{
|
{
|
||||||
enum { Major = 0 };
|
enum { Major = 0 };
|
||||||
enum { Minor = 5 };
|
enum { Minor = 5 };
|
||||||
enum { Patch = 4 };
|
enum { Patch = 5 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,15 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
f.Read( m_data.lastTime );
|
f.Read( m_data.lastTime );
|
||||||
f.Read( m_data.frameOffset );
|
f.Read( m_data.frameOffset );
|
||||||
|
|
||||||
|
if( fileVer >= FileVersion( 0, 5, 5 ) )
|
||||||
|
{
|
||||||
|
f.Read( m_pid );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t sz;
|
uint64_t sz;
|
||||||
{
|
{
|
||||||
f.Read( sz );
|
f.Read( sz );
|
||||||
@ -2099,6 +2108,7 @@ void Worker::Exec()
|
|||||||
m_data.lastTime = initEnd;
|
m_data.lastTime = initEnd;
|
||||||
m_delay = TscTime( welcome.delay );
|
m_delay = TscTime( welcome.delay );
|
||||||
m_resolution = TscTime( welcome.resolution );
|
m_resolution = TscTime( welcome.resolution );
|
||||||
|
m_pid = welcome.pid;
|
||||||
m_onDemand = welcome.onDemand;
|
m_onDemand = welcome.onDemand;
|
||||||
m_captureProgram = welcome.programName;
|
m_captureProgram = welcome.programName;
|
||||||
m_captureTime = welcome.epoch;
|
m_captureTime = welcome.epoch;
|
||||||
@ -4676,6 +4686,7 @@ void Worker::Write( FileWrite& f )
|
|||||||
f.Write( &m_timerMul, sizeof( m_timerMul ) );
|
f.Write( &m_timerMul, sizeof( m_timerMul ) );
|
||||||
f.Write( &m_data.lastTime, sizeof( m_data.lastTime ) );
|
f.Write( &m_data.lastTime, sizeof( m_data.lastTime ) );
|
||||||
f.Write( &m_data.frameOffset, sizeof( m_data.frameOffset ) );
|
f.Write( &m_data.frameOffset, sizeof( m_data.frameOffset ) );
|
||||||
|
f.Write( &m_pid, sizeof( m_pid ) );
|
||||||
|
|
||||||
uint64_t sz = m_captureName.size();
|
uint64_t sz = m_captureName.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
@ -274,6 +274,7 @@ public:
|
|||||||
const std::string& GetHostInfo() const { return m_hostInfo; }
|
const std::string& GetHostInfo() const { return m_hostInfo; }
|
||||||
int64_t GetDelay() const { return m_delay; }
|
int64_t GetDelay() const { return m_delay; }
|
||||||
int64_t GetResolution() const { return m_resolution; }
|
int64_t GetResolution() const { return m_resolution; }
|
||||||
|
uint64_t GetPid() const { return m_pid; };
|
||||||
|
|
||||||
std::shared_mutex& GetDataLock() { return m_data.lock; }
|
std::shared_mutex& GetDataLock() { return m_data.lock; }
|
||||||
size_t GetFrameCount( const FrameData& fd ) const { return fd.frames.size(); }
|
size_t GetFrameCount( const FrameData& fd ) const { return fd.frames.size(); }
|
||||||
@ -544,6 +545,7 @@ private:
|
|||||||
std::string m_captureProgram;
|
std::string m_captureProgram;
|
||||||
uint64_t m_captureTime;
|
uint64_t m_captureTime;
|
||||||
std::string m_hostInfo;
|
std::string m_hostInfo;
|
||||||
|
uint64_t m_pid;
|
||||||
bool m_terminate = false;
|
bool m_terminate = false;
|
||||||
bool m_crashed = false;
|
bool m_crashed = false;
|
||||||
bool m_disconnect = false;
|
bool m_disconnect = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user