From 930ef77ea918d175a14c47f55aa578afa6b0ac10 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 10 Oct 2021 14:12:13 +0200 Subject: [PATCH] Add zone value failure context. --- server/TracyView.cpp | 4 ++++ server/TracyWorker.cpp | 15 +++++++++++++-- server/TracyWorker.hpp | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 1a9c8cfd..d7121f5f 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -480,6 +480,10 @@ bool View::Draw() ImGui::SameLine(); ImGui::TextDisabled( "(%s)", RealToString( data.thread ) ); } + if( !data.message.empty() ) + { + TextFocused( "Context:", data.message.c_str() ); + } if( data.callstack != 0 ) { if( ImGui::TreeNode( "Call stack" ) ) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 99222f6d..68eff753 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -4844,10 +4844,21 @@ void Worker::ZoneTextFailure( uint64_t thread ) m_failureData.thread = thread; } -void Worker::ZoneValueFailure( uint64_t thread ) +void Worker::ZoneValueFailure( uint64_t thread, uint64_t value ) { + char buf[128]; + if( (int64_t)value < 0 ) + { + sprintf( buf, "Zone value was: %" PRIu64 " (unsigned), %" PRIi64 " (signed)", value, (int64_t)value ); + } + else + { + sprintf( buf, "Zone value was: %" PRIu64, value ); + } + m_failure = Failure::ZoneValue; m_failureData.thread = thread; + m_failureData.message = buf; } void Worker::ZoneColorFailure( uint64_t thread ) @@ -5120,7 +5131,7 @@ void Worker::ProcessZoneValue( const QueueZoneValue& ev ) auto td = RetrieveThread( m_threadCtx ); if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() ) { - ZoneValueFailure( m_threadCtx ); + ZoneValueFailure( m_threadCtx, ev.value ); return; } diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 9f1d3ac2..a4a641da 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -381,6 +381,7 @@ private: uint64_t thread; int16_t srcloc; uint32_t callstack; + std::string message; }; struct FrameImagePending @@ -715,7 +716,7 @@ private: void ZoneStackFailure( uint64_t thread, const ZoneEvent* ev ); void ZoneDoubleEndFailure( uint64_t thread, const ZoneEvent* ev ); void ZoneTextFailure( uint64_t thread ); - void ZoneValueFailure( uint64_t thread ); + void ZoneValueFailure( uint64_t thread, uint64_t value ); void ZoneColorFailure( uint64_t thread ); void ZoneNameFailure( uint64_t thread ); void MemFreeFailure( uint64_t thread );