Welcome to mirror list, hosted at ThFree Co, Russian Federation.

identify.cpp « extra - github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d767b22400a52d53b44656b49396b16f03c2526d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// g++ identify.cpp -lpthread ../public/common/tracy_lz4.cpp ../zstd/common/*.c ../zstd/decompress/*.c ../zstd/decompress/huf_decompress_amd64.S

#include <memory>
#include <stdint.h>
#include <stdio.h>

#include "../server/TracyFileRead.hpp"
#include "../public/common/TracyVersion.hpp"

static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch };
enum { FileHeaderMagic = 5 };

int main( int argc, char** argv )
{
    if( argc != 2 )
    {
        fprintf( stderr, "Usage: %s trace\n", argv[0] );
        return -1;
    }

    try
    {
        std::unique_ptr<tracy::FileRead> f( tracy::FileRead::Open( argv[1] ) );
        if( !f )
        {
            fprintf( stderr, "%s: Cannot open!\n", argv[1] );
            return -2;
        }

        uint8_t hdr[8];
        f->Read( hdr, sizeof( hdr ) );
        if( memcmp( FileHeader, hdr, FileHeaderMagic ) != 0 )
        {
            fprintf( stderr, "%s: Bad header!\n", argv[1] );
            return -3;
        }

        printf( "%s: %i.%i.%i\n", argv[1], hdr[FileHeaderMagic], hdr[FileHeaderMagic+1], hdr[FileHeaderMagic+2] );
    }
    catch( const tracy::NotTracyDump& )
    {
        fprintf( stderr, "%s: Not a tracy dump!\n", argv[1] );
        return -4;
    }
    catch( const tracy::FileReadError& )
    {
        fprintf( stderr, "%s: File read error!\n", argv[1] );
        return -5;
    }
}