Send crash report.

This commit is contained in:
Bartosz Taudul 2018-08-20 02:07:31 +02:00
parent 49e36c013f
commit 3b526b074e
5 changed files with 59 additions and 2 deletions

View File

@ -357,7 +357,20 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
return EXCEPTION_CONTINUE_SEARCH;
}
Profiler::Message( "!!!CRASH!!!" );
{
const auto thread = GetThreadHandle();
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
MemWrite( &item->hdr.type, QueueType::CrashReport );
item->crashReport.time = Profiler::GetTime();
item->crashReport.thread = thread;
item->crashReport.text = (uint64_t)s_crashText;
tail.store( magic + 1, std::memory_order_release );
s_profiler.SendCallstack( 60, thread );
}
HANDLE h = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if( h == INVALID_HANDLE_VALUE ) return EXCEPTION_CONTINUE_SEARCH;

View File

@ -17,6 +17,7 @@ enum class QueueType : uint8_t
Terminate,
KeepAlive,
Crash,
CrashReport,
ZoneBegin,
ZoneBeginCallstack,
ZoneEnd,
@ -235,6 +236,13 @@ struct QueueCallstackFrame
uint32_t line;
};
struct QueueCrashReport
{
int64_t time;
uint64_t thread;
uint64_t text; // ptr
};
struct QueueHeader
{
union
@ -271,6 +279,7 @@ struct QueueItem
QueueCallstackMemory callstackMemory;
QueueCallstack callstack;
QueueCallstackFrame callstackFrame;
QueueCrashReport crashReport;
};
};
@ -289,6 +298,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ), // terminate
sizeof( QueueHeader ), // keep alive
sizeof( QueueHeader ), // crash
sizeof( QueueHeader ) + sizeof( QueueCrashReport ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),

View File

@ -181,6 +181,17 @@ struct CallstackFrameTree
enum { CallstackFrameTreeSize = sizeof( CallstackFrameTree ) };
struct CrashEvent
{
uint64_t thread = 0;
int64_t time = 0;
uint64_t message = 0;
uint32_t callstack = 0;
};
enum { CrashEventSize = sizeof( CrashEvent ) };
#pragma pack()

View File

@ -1929,6 +1929,9 @@ void Worker::Process( const QueueItem& ev )
case QueueType::Crash:
m_crashed = true;
break;
case QueueType::CrashReport:
ProcessCrashReport( ev.crashReport );
break;
default:
assert( false );
break;
@ -2574,6 +2577,9 @@ void Worker::ProcessCallstack( const QueueCallstack& ev )
case NextCallstackType::Gpu:
next.gpu->callstack = it->second;
break;
case NextCallstackType::Crash:
m_data.m_crashEvent.callstack = it->second;
break;
default:
assert( false );
break;
@ -2610,6 +2616,19 @@ void Worker::ProcessCallstackFrame( const QueueCallstackFrame& ev )
m_pendingCustomStrings.erase( m_pendingCustomStrings.find( ev.file ) );
}
void Worker::ProcessCrashReport( const QueueCrashReport& ev )
{
CheckString( ev.text );
auto& next = m_nextCallstack[ev.thread];
next.type = NextCallstackType::Crash;
m_data.m_crashEvent.thread = ev.thread;
m_data.m_crashEvent.time = TscTime( ev.time );
m_data.m_crashEvent.message = ev.text;
m_data.m_crashEvent.callstack = 0;
}
void Worker::MemAllocChanged( int64_t time )
{
const auto val = (double)m_data.memory.usage;

View File

@ -140,6 +140,8 @@ private:
std::vector<Vector<ZoneEvent*>> m_zoneChildren;
std::vector<Vector<GpuEvent*>> m_gpuChildren;
CrashEvent m_crashEvent;
};
struct MbpsBlock
@ -154,7 +156,8 @@ private:
enum class NextCallstackType
{
Zone,
Gpu
Gpu,
Crash
};
struct NextCallstack
@ -297,6 +300,7 @@ private:
tracy_force_inline void ProcessCallstackMemory( const QueueCallstackMemory& ev );
tracy_force_inline void ProcessCallstack( const QueueCallstack& ev );
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev );