diff --git a/NEWS b/NEWS index f665c249..d2e8bda9 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ v0.5 (xxxx-xx-xx) after the connection to the client is terminated. - Active trace can be discarded. - Call stack capture may be forced through TRACY_CALLSTACK define. +- Lock info window has been added. v0.4 (2018-10-09) ----------------- diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 14c85846..b209b3a3 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -293,6 +293,7 @@ View::View( const char* addr, ImFont* fixedWidth, SetTitleCallback stcb ) , m_memoryAllocHover( -1 ) , m_memoryAllocHoverWait( 0 ) , m_frames( nullptr ) + , m_lockInfoWindow( InvalidId ) , m_gpuThread( 0 ) , m_gpuStart( 0 ) , m_gpuEnd( 0 ) @@ -340,6 +341,7 @@ View::View( FileRead& f, ImFont* fixedWidth, SetTitleCallback stcb ) , m_memoryAllocHover( -1 ) , m_memoryAllocHoverWait( 0 ) , m_frames( m_worker.GetFramesBase() ) + , m_lockInfoWindow( InvalidId ) , m_gpuThread( 0 ) , m_gpuStart( 0 ) , m_gpuEnd( 0 ) @@ -750,6 +752,7 @@ bool View::DrawImpl() if( m_showInfo ) DrawInfo(); if( m_textEditorFile ) DrawTextEditor(); if( m_goToFrame ) DrawGoToFrame(); + if( m_lockInfoWindow != InvalidId ) DrawLockInfoWindow(); const auto& io = ImGui::GetIO(); if( m_zoomAnim.active ) @@ -774,6 +777,7 @@ bool View::DrawImpl() m_zoneinfoBuzzAnim.Update( io.DeltaTime ); m_findZoneBuzzAnim.Update( io.DeltaTime ); m_optionsLockBuzzAnim.Update( io.DeltaTime ); + m_lockInfoAnim.Update( io.DeltaTime ); return keepOpen; } @@ -3119,6 +3123,11 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, ImGui::Separator(); TextFocused( "Lock events:", RealToString( v.second.timeline.size(), true ) ); ImGui::EndTooltip(); + + if( ImGui::IsMouseClicked( 0 ) ) + { + m_lockInfoWindow = v.first; + } } cnt++; } @@ -7070,6 +7079,71 @@ void View::DrawGoToFrame() ImGui::End(); } +void View::DrawLockInfoWindow() +{ + auto it = m_worker.GetLockMap().find( m_lockInfoWindow ); + assert( it != m_worker.GetLockMap().end() ); + const auto& lock = it->second; + const auto& srcloc = m_worker.GetSourceLocation( lock.srcloc ); + auto fileName = m_worker.GetString( srcloc.file ); + + bool visible = true; + ImGui::Begin( "Lock info", &visible, ImGuiWindowFlags_AlwaysAutoResize ); + ImGui::Text( "Lock #%" PRIu32 ": %s", m_lockInfoWindow, m_worker.GetString( srcloc.function ) ); + ImGui::TextDisabled( "Location:" ); + if( m_lockInfoAnim.Match( m_lockInfoWindow ) ) + { + const auto time = m_lockInfoAnim.Time(); + const auto indentVal = sin( time * 60.f ) * 10.f * time; + ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal ); + } + else + { + ImGui::SameLine(); + } + ImGui::Text( "%s:%i", fileName, srcloc.line ); + if( ImGui::IsItemClicked( 1 ) ) + { + if( FileExists( fileName ) ) + { + SetTextEditorFile( fileName, srcloc.line ); + } + else + { + m_lockInfoAnim.Enable( m_lockInfoWindow, 0.5f ); + } + } + switch( lock.type ) + { + case LockType::Lockable: + TextFocused( "Type:", "lockable" ); + break; + case LockType::SharedLockable: + TextFocused( "Type:", "shared lockable" ); + break; + default: + assert( false ); + break; + } + TextFocused( "Lock events:", RealToString( lock.timeline.size(), true ) ); + ImGui::Separator(); + const auto threadList = ImGui::TreeNode( "Thread list" ); + ImGui::SameLine(); + ImGui::TextDisabled( "(%zu)", lock.threadList.size() ); + if( threadList ) + { + for( const auto& t : lock.threadList ) + { + ImGui::Text( "%s", m_worker.GetThreadString( t ) ); + ImGui::SameLine(); + ImGui::TextDisabled( "(0x%" PRIX64 ")", t ); + } + ImGui::TreePop(); + } + ImGui::End(); + if( !visible ) m_lockInfoWindow = InvalidId; +} + template void View::ListMemData( T ptr, T end, std::function DrawAddress, const char* id ) { diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 275d8b3a..5d592ae6 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -64,6 +64,8 @@ private: Short }; + enum { InvalidId = 0xFFFFFFFF }; + void InitTextEditor(); const char* ShortenNamespace( const char* name ) const; @@ -100,6 +102,7 @@ private: void DrawInfo(); void DrawTextEditor(); void DrawGoToFrame(); + void DrawLockInfoWindow(); template void ListMemData( T ptr, T end, std::function DrawAddress, const char* id = nullptr ); @@ -228,6 +231,7 @@ private: int64_t m_memoryAllocHover; int m_memoryAllocHoverWait; const FrameData* m_frames; + uint32_t m_lockInfoWindow; Region m_highlight; Region m_highlightZoom; @@ -258,6 +262,7 @@ private: BuzzAnim m_zoneinfoBuzzAnim; BuzzAnim m_findZoneBuzzAnim; BuzzAnim m_optionsLockBuzzAnim; + BuzzAnim m_lockInfoAnim; Vector m_zoneInfoStack; Vector m_gpuInfoStack;