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.
This commit is contained in:
Bartosz Taudul 2018-08-20 01:03:16 +02:00
parent ca939ccd19
commit 366ea35593
3 changed files with 17 additions and 6 deletions

View File

@ -16,6 +16,7 @@ enum class QueueType : uint8_t
Callstack, Callstack,
Terminate, Terminate,
KeepAlive, KeepAlive,
Crash,
ZoneBegin, ZoneBegin,
ZoneBeginCallstack, ZoneBeginCallstack,
ZoneEnd, ZoneEnd,
@ -287,6 +288,7 @@ static const size_t QueueDataSize[] = {
// above items must be first // above items must be first
sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // terminate
sizeof( QueueHeader ), // keep alive sizeof( QueueHeader ), // keep alive
sizeof( QueueHeader ), // crash
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ), sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),

View File

@ -192,6 +192,7 @@ Worker::Worker( const char* addr )
, m_hasData( false ) , m_hasData( false )
, m_shutdown( false ) , m_shutdown( false )
, m_terminate( false ) , m_terminate( false )
, m_crashed( false )
, m_stream( LZ4_createStreamDecode() ) , m_stream( LZ4_createStreamDecode() )
, m_buffer( new char[TargetFrameSize*3 + 1] ) , m_buffer( new char[TargetFrameSize*3 + 1] )
, m_bufferOffset( 0 ) , m_bufferOffset( 0 )
@ -220,6 +221,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
, m_hasData( true ) , m_hasData( true )
, m_shutdown( false ) , m_shutdown( false )
, m_terminate( false ) , m_terminate( false )
, m_crashed( false )
, m_stream( nullptr ) , m_stream( nullptr )
, m_buffer( nullptr ) , m_buffer( nullptr )
{ {
@ -1315,16 +1317,19 @@ void Worker::Exec()
{ {
continue; continue;
} }
bool done = true; if( !m_crashed )
for( auto& v : m_data.threads )
{ {
if( !v->stack.empty() ) bool done = true;
for( auto& v : m_data.threads )
{ {
done = false; if( !v->stack.empty() )
break; {
done = false;
break;
}
} }
if( !done ) continue;
} }
if( !done ) continue;
ServerQuery( ServerQueryTerminate, 0 ); ServerQuery( ServerQueryTerminate, 0 );
break; break;
} }
@ -1921,6 +1926,9 @@ void Worker::Process( const QueueItem& ev )
break; break;
case QueueType::KeepAlive: case QueueType::KeepAlive:
break; break;
case QueueType::Crash:
m_crashed = true;
break;
default: default:
assert( false ); assert( false );
break; break;

View File

@ -375,6 +375,7 @@ private:
std::string m_captureName; std::string m_captureName;
std::string m_hostInfo; std::string m_hostInfo;
bool m_terminate; bool m_terminate;
bool m_crashed;
LZ4_streamDecode_t* m_stream; LZ4_streamDecode_t* m_stream;
char* m_buffer; char* m_buffer;
int m_bufferOffset; int m_bufferOffset;