From 048ff8213a6c6fa4fb9b8df43d53f4ea83764402 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 2 Jun 2024 12:56:25 +0200 Subject: [PATCH] Support loading single-stream new format traces. --- server/TracyFileRead.hpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index 6747b45e..22f49bb5 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -349,7 +349,39 @@ private: fclose( f ); throw NotTracyDump(); } - if( memcmp( hdr, Lz4Header, sizeof( hdr ) ) == 0 ) + + uint8_t streams = 1; + m_dataOffset = sizeof( hdr ); + + if( memcmp( hdr, TracyHeader, sizeof( hdr ) ) == 0 ) + { + uint8_t type; + if( fread( &type, 1, 1, f ) != 1 ) + { + fclose( f ); + throw NotTracyDump(); + } + switch( type ) + { + case 0: + m_stream = LZ4_createStreamDecode(); + break; + case 1: + m_streamZstd = ZSTD_createDStream(); + break; + default: + fclose( f ); + throw NotTracyDump(); + break; + } + if( fread( &streams, 1, 1, f ) != 1 ) + { + fclose( f ); + throw NotTracyDump(); + } + m_dataOffset += 2; + } + else if( memcmp( hdr, Lz4Header, sizeof( hdr ) ) == 0 ) { m_stream = LZ4_createStreamDecode(); } @@ -380,7 +412,6 @@ private: { throw FileReadError(); } - m_dataOffset = sizeof( hdr ); ReadBlock( ReadBlockSize() ); std::swap( m_buf, m_second );