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
|
||||
{
|
||||
|
||||
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 )
|
||||
{
|
||||
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 )
|
||||
: m_addr( addr )
|
||||
, m_connected( false )
|
||||
@ -61,6 +62,11 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
if( memcmp( FileHeader, hdr, FileHeaderMagic ) == 0 )
|
||||
{
|
||||
fileVer = FileVersion( hdr[FileHeaderMagic], hdr[FileHeaderMagic+1], hdr[FileHeaderMagic+2] );
|
||||
if( fileVer > CurrentVersion )
|
||||
{
|
||||
throw UnsupportedVersion( fileVer );
|
||||
}
|
||||
|
||||
f.Read( &m_delay, sizeof( m_delay ) );
|
||||
}
|
||||
else
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <atomic>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@ -37,6 +38,12 @@ namespace EventType
|
||||
};
|
||||
}
|
||||
|
||||
struct UnsupportedVersion : public std::exception
|
||||
{
|
||||
UnsupportedVersion( int version ) : version( version ) {}
|
||||
int version;
|
||||
};
|
||||
|
||||
class Worker
|
||||
{
|
||||
#pragma pack( 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user