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

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorBartosz Taudul <wolf@nereid.pl>2021-05-18 03:49:41 +0300
committerBartosz Taudul <wolf@nereid.pl>2021-05-18 03:49:41 +0300
commit6d8abfe640e0eb34a6eab1bb4529dee291d6d505 (patch)
tree4147669309e85f578e436d07b6322f38cb195de4 /extra
parent5ec1313af1e1a39832005c1a9546cb6e216b145b (diff)
Add utility for trace version identification.
Diffstat (limited to 'extra')
-rw-r--r--extra/identify.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/extra/identify.cpp b/extra/identify.cpp
new file mode 100644
index 00000000..897eba9a
--- /dev/null
+++ b/extra/identify.cpp
@@ -0,0 +1,50 @@
+// g++ identify.cpp -lpthread ../common/tracy_lz4.cpp ../zstd/common/*.c ../zstd/decompress/*.c
+
+#include <memory>
+#include <stdint.h>
+#include <stdio.h>
+
+#include "../server/TracyFileRead.hpp"
+#include "../server/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;
+ }
+}