1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Store explicit program name and capture time.

This commit is contained in:
Bartosz Taudul 2018-08-29 00:57:11 +02:00
parent 128577d7bf
commit 8f1acf2571
3 changed files with 45 additions and 1 deletions

View File

@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 3 };
enum { Patch = 204 };
enum { Patch = 205 };
}
}

View File

@ -278,6 +278,38 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
m_captureName = std::string( tmp, tmp+sz );
}
if( fileVer >= FileVersion( 0, 3, 205 ) )
{
f.Read( sz );
assert( sz < 1024 );
char tmp[1024];
f.Read( tmp, sz );
m_captureProgram = std::string( tmp, tmp+sz );
f.Read( m_captureTime );
}
else
{
const auto sz = m_captureName.size();
char tmp[1024];
memcpy( tmp, m_captureName.c_str(), sz );
tmp[sz] = '\0';
auto ptr = tmp + sz - 1;
while( *ptr != '@' )
{
if( *ptr == '#' ) *ptr = '\0';
ptr--;
}
m_captureProgram = std::string( tmp, ptr-1 );
tm epoch = {};
sscanf( ptr+1, "%d-%d-%d %d:%d:%d", &epoch.tm_year, &epoch.tm_mon, &epoch.tm_mday, &epoch.tm_hour, &epoch.tm_min, &epoch.tm_sec );
epoch.tm_year -= 1900;
epoch.tm_mon--;
m_captureTime = (uint64_t)mktime( &epoch );
}
if( fileVer >= FileVersion( 0, 3, 203 ) )
{
f.Read( sz );
@ -1244,6 +1276,8 @@ void Worker::Exec()
m_delay = TscTime( welcome.delay );
m_resolution = TscTime( welcome.resolution );
m_onDemand = welcome.onDemand;
m_captureProgram = welcome.programName;
m_captureTime = welcome.epoch;
char dtmp[64];
time_t date = welcome.epoch;
@ -2980,6 +3014,12 @@ void Worker::Write( FileWrite& f )
f.Write( &sz, sizeof( sz ) );
f.Write( m_captureName.c_str(), sz );
sz = m_captureProgram.size();
f.Write( &sz, sizeof( sz ) );
f.Write( m_captureProgram.c_str(), sz );
f.Write( &m_captureTime, sizeof( m_captureTime ) );
sz = m_hostInfo.size();
f.Write( &sz, sizeof( sz ) );
f.Write( m_hostInfo.c_str(), sz );

View File

@ -177,6 +177,8 @@ public:
const std::string& GetAddr() const { return m_addr; }
const std::string& GetCaptureName() const { return m_captureName; }
const std::string& GetCaptureProgram() const { return m_captureProgram; }
uint64_t GetCaptureTime() const { return m_captureTime; }
const std::string& GetHostInfo() const { return m_hostInfo; }
int64_t GetDelay() const { return m_delay; }
int64_t GetResolution() const { return m_resolution; }
@ -379,6 +381,8 @@ private:
int64_t m_resolution;
double m_timerMul;
std::string m_captureName;
std::string m_captureProgram;
uint64_t m_captureTime;
std::string m_hostInfo;
bool m_terminate;
bool m_crashed;