From 366ea35593cd22cef4ae598c8089fe81c2460557 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 20 Aug 2018 01:03:16 +0200 Subject: [PATCH] Allow crash event reporting. When crash happens there's no longer anything to profile -- don't wait for unfinished zones to finish before sending client terminate confirmation. --- common/TracyQueue.hpp | 2 ++ server/TracyWorker.cpp | 20 ++++++++++++++------ server/TracyWorker.hpp | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 780ccf69..927fa9ef 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -16,6 +16,7 @@ enum class QueueType : uint8_t Callstack, Terminate, KeepAlive, + Crash, ZoneBegin, ZoneBeginCallstack, ZoneEnd, @@ -287,6 +288,7 @@ static const size_t QueueDataSize[] = { // above items must be first sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // keep alive + sizeof( QueueHeader ), // crash sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack sizeof( QueueHeader ) + sizeof( QueueZoneEnd ), diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 00861e2c..598ec78e 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -192,6 +192,7 @@ Worker::Worker( const char* addr ) , m_hasData( false ) , m_shutdown( false ) , m_terminate( false ) + , m_crashed( false ) , m_stream( LZ4_createStreamDecode() ) , m_buffer( new char[TargetFrameSize*3 + 1] ) , m_bufferOffset( 0 ) @@ -220,6 +221,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask ) , m_hasData( true ) , m_shutdown( false ) , m_terminate( false ) + , m_crashed( false ) , m_stream( nullptr ) , m_buffer( nullptr ) { @@ -1315,16 +1317,19 @@ void Worker::Exec() { continue; } - bool done = true; - for( auto& v : m_data.threads ) + if( !m_crashed ) { - if( !v->stack.empty() ) + bool done = true; + for( auto& v : m_data.threads ) { - done = false; - break; + if( !v->stack.empty() ) + { + done = false; + break; + } } + if( !done ) continue; } - if( !done ) continue; ServerQuery( ServerQueryTerminate, 0 ); break; } @@ -1921,6 +1926,9 @@ void Worker::Process( const QueueItem& ev ) break; case QueueType::KeepAlive: break; + case QueueType::Crash: + m_crashed = true; + break; default: assert( false ); break; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 49aeaf48..84580162 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -375,6 +375,7 @@ private: std::string m_captureName; std::string m_hostInfo; bool m_terminate; + bool m_crashed; LZ4_streamDecode_t* m_stream; char* m_buffer; int m_bufferOffset;