diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 830786d4..cb22b73d 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3287,7 +3287,7 @@ void View::DrawZones() auto ctxSwitch = m_worker.GetContextSwitchData( v->id ); if( ctxSwitch ) { - DrawContextSwitches( ctxSwitch, hover, pxns, int64_t( nspx ), wpos, ctxOffset, offset, v->isFiber ); + DrawContextSwitches( ctxSwitch, v->samples, hover, pxns, int64_t( nspx ), wpos, ctxOffset, offset, v->isFiber ); } } @@ -3875,7 +3875,7 @@ static const char* DecodeContextSwitchState( uint8_t state ) } } -void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber ) +void View::DrawContextSwitches( const ContextSwitch* ctx, const Vector& sampleData, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber ) { auto& vec = ctx->v; auto it = std::lower_bound( vec.begin(), vec.end(), std::max( 0, m_vd.zvStart ), [] ( const auto& l, const auto& r ) { return (uint64_t)l.End() < (uint64_t)r; } ); @@ -3917,6 +3917,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn if( hover ) { + bool tooltip = false; if( ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( pxw, offset + ty ) ) ) { ImGui::BeginTooltip(); @@ -3949,7 +3950,7 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn ImGui::SameLine(); TextDisabledUnformatted( DecodeContextSwitchState( pit->State() ) ); } - ImGui::EndTooltip(); + tooltip = true; if( IsMouseClicked( 2 ) ) { @@ -3967,6 +3968,20 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn { ZoomToRange( pit->End(), ev.WakeupVal() ); } + tooltip = true; + } + if( tooltip ) + { + if( !sampleData.empty() ) + { + auto sdit = std::lower_bound( sampleData.begin(), sampleData.end(), ev.Start(), [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } ); + if( sdit != sampleData.end() && sdit->time.Val() == ev.Start() ) + { + ImGui::Separator(); + TextDisabledUnformatted( "Wait stack:" ); + CallstackTooltipContents( sdit->callstack.Val() ); + } + } ImGui::EndTooltip(); } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 037bfbd5..b14c1cdc 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -174,7 +174,7 @@ private: void DrawZoneFramesHeader(); void DrawZoneFrames( const FrameData& frames ); void DrawZones(); - void DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber ); + void DrawContextSwitches( const ContextSwitch* ctx, const Vector& sampleData, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int endOffset, bool isFiber ); void DrawSamples( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset ); #ifndef TRACY_NO_STATISTICS int DispatchGhostLevel( const Vector& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int offset, int depth, float yMin, float yMax, uint64_t tid );