mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Throw exception when trying to open unsupported dump version.
This commit is contained in:
parent
3793a37b2b
commit
36efe96e9d
@ -19,14 +19,15 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', 0, 3, 0 };
|
|
||||||
enum { FileHeaderMagic = 5 };
|
|
||||||
|
|
||||||
static constexpr int FileVersion( uint8_t h5, uint8_t h6, uint8_t h7 )
|
static constexpr int FileVersion( uint8_t h5, uint8_t h6, uint8_t h7 )
|
||||||
{
|
{
|
||||||
return ( h5 << 16 ) | ( h6 << 8 ) | h7;
|
return ( h5 << 16 ) | ( h6 << 8 ) | h7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', 0, 3, 0 };
|
||||||
|
enum { FileHeaderMagic = 5 };
|
||||||
|
static const int CurrentVersion = FileVersion( FileHeader[FileHeaderMagic], FileHeader[FileHeaderMagic+1], FileHeader[FileHeaderMagic+2] );
|
||||||
|
|
||||||
Worker::Worker( const char* addr )
|
Worker::Worker( const char* addr )
|
||||||
: m_addr( addr )
|
: m_addr( addr )
|
||||||
, m_connected( false )
|
, m_connected( false )
|
||||||
@ -61,6 +62,11 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
if( memcmp( FileHeader, hdr, FileHeaderMagic ) == 0 )
|
if( memcmp( FileHeader, hdr, FileHeaderMagic ) == 0 )
|
||||||
{
|
{
|
||||||
fileVer = FileVersion( hdr[FileHeaderMagic], hdr[FileHeaderMagic+1], hdr[FileHeaderMagic+2] );
|
fileVer = FileVersion( hdr[FileHeaderMagic], hdr[FileHeaderMagic+1], hdr[FileHeaderMagic+2] );
|
||||||
|
if( fileVer > CurrentVersion )
|
||||||
|
{
|
||||||
|
throw UnsupportedVersion( fileVer );
|
||||||
|
}
|
||||||
|
|
||||||
f.Read( &m_delay, sizeof( m_delay ) );
|
f.Read( &m_delay, sizeof( m_delay ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -37,6 +38,12 @@ namespace EventType
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct UnsupportedVersion : public std::exception
|
||||||
|
{
|
||||||
|
UnsupportedVersion( int version ) : version( version ) {}
|
||||||
|
int version;
|
||||||
|
};
|
||||||
|
|
||||||
class Worker
|
class Worker
|
||||||
{
|
{
|
||||||
#pragma pack( 1 )
|
#pragma pack( 1 )
|
||||||
|
Loading…
Reference in New Issue
Block a user