Save "on demand" flag in traces.

Previously on demand mode was determined by frame offset parameter being
greater than zero. However, if the application is not pumping frames with
FrameMark macro, the frame index will never increase and the frame offset
parameter stay at zero. It is not possible to distinguish on demand traces
from normal ones in this scenario.

Fix by explicitly saving the on demand flag in trace file and employ the
previous logic to set the flag when importing older traces.
This commit is contained in:
Bartosz Taudul 2023-03-04 00:11:32 +01:00
parent ed79c4f241
commit e92874c0bb
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 16 additions and 1 deletions

View File

@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 9 };
enum { Patch = 1 };
enum { Patch = 2 };
}
}

View File

@ -312,6 +312,7 @@ Worker::Worker( const char* name, const char* program, const std::vector<ImportE
, m_samplingPeriod( 0 )
, m_stream( nullptr )
, m_buffer( nullptr )
, m_onDemand( false )
, m_inconsistentSamples( false )
, m_traceVersion( CurrentVersion )
{
@ -589,6 +590,17 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks )
f.Read( m_data.cpuManufacturer, 12 );
m_data.cpuManufacturer[12] = '\0';
if( fileVer >= FileVersion( 0, 9, 2 ) )
{
uint8_t flag;
f.Read( flag );
m_onDemand = flag;
}
else
{
m_onDemand = m_data.frameOffset != 0;
}
uint64_t sz;
{
f.Read( sz );
@ -7656,6 +7668,9 @@ void Worker::Write( FileWrite& f, bool fiDict )
f.Write( &m_data.cpuId, sizeof( m_data.cpuId ) );
f.Write( m_data.cpuManufacturer, 12 );
uint8_t flag = m_onDemand;
f.Write( &flag, sizeof( flag ) );
uint64_t sz = m_captureName.size();
f.Write( &sz, sizeof( sz ) );
f.Write( m_captureName.c_str(), sz );