From c3246ca3b5a2cb04a7c952e1bc65471c2edb2880 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 14 Jan 2019 23:22:31 +0100 Subject: [PATCH] Gracefully store failure states. --- server/TracyWorker.cpp | 13 ++++++++++++- server/TracyWorker.hpp | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 9749da20..1396b4d8 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2282,7 +2282,11 @@ bool Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) auto td = tit->second; assert( !td->zoneIdStack.empty() ); auto zoneId = td->zoneIdStack.back_and_pop(); - if( zoneId != td->nextZoneId ) return false; + if( zoneId != td->nextZoneId ) + { + ZoneStackFailure( ev.thread, td->stack.back() ); + return false; + } td->nextZoneId = 0; auto& stack = td->stack; @@ -2320,6 +2324,13 @@ bool Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) return true; } +void Worker::ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ) +{ + m_failure = Failure::ZoneStack; + m_failureData.thread = thread; + m_failureData.srcloc = ev->srcloc; +} + void Worker::ProcessZoneValidation( const QueueZoneValidation& ev ) { auto td = NoticeThread( ev.thread ); diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 4434a993..f545434b 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -170,7 +170,19 @@ private: }; }; + struct FailureData + { + uint64_t thread; + int32_t srcloc; + }; + public: + enum class Failure + { + None, + ZoneStack + }; + Worker( const char* addr ); Worker( FileRead& f, EventType::Type eventMask = EventType::All ); ~Worker(); @@ -269,6 +281,10 @@ public: static const LoadProgress& GetLoadProgress() { return s_loadProgress; } int64_t GetLoadTime() const { return m_loadTime; } + void ClearFailure() { m_failure = Failure::None; } + Failure GetFailureType() const { return m_failure; } + const FailureData& GetFailureData() const { return m_failureData; } + private: void Exec(); void ServerQuery( uint8_t type, uint64_t data ); @@ -314,6 +330,8 @@ private: tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev ); tracy_force_inline void ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& ev ); + void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); + tracy_force_inline void CheckSourceLocation( uint64_t ptr ); void NewSourceLocation( uint64_t ptr ); tracy_force_inline uint32_t ShrinkSourceLocation( uint64_t srcloc ); @@ -423,6 +441,9 @@ private: static LoadProgress s_loadProgress; int64_t m_loadTime; + + Failure m_failure = Failure::None; + FailureData m_failureData; }; }